示例#1
0
            /// <summary>
            ///     Densely-connected layer class. aka fully-connected<br></br>
            ///     `outputs = activation(inputs * kernel + bias)`
            /// </summary>
            /// <param name="inputs"></param>
            /// <param name="units">Python integer, dimensionality of the output space.</param>
            /// <param name="activation"></param>
            /// <param name="use_bias">Boolean, whether the layer uses a bias.</param>
            /// <param name="kernel_initializer"></param>
            /// <param name="bias_initializer"></param>
            /// <param name="trainable"></param>
            /// <param name="name"></param>
            /// <param name="reuse"></param>
            /// <returns></returns>
            public Tensor dense(Tensor inputs,
                                int units,
                                Activation activation           = null,
                                bool use_bias                   = true,
                                IInitializer kernel_initializer = null,
                                IInitializer bias_initializer   = null,
                                bool trainable                  = true,
                                string name = null,
                                bool?reuse  = null)
            {
                if (bias_initializer == null)
                {
                    bias_initializer = tf.zeros_initializer;
                }

                var layer = new Dense(new DenseArgs
                {
                    Units             = units,
                    Activation        = activation,
                    UseBias           = use_bias,
                    BiasInitializer   = bias_initializer,
                    KernelInitializer = kernel_initializer,
                    Trainable         = trainable,
                    Name = name
                });

                return(layer.Apply(inputs));
            }