tf.contrib.layers.fully_connected(*args, **kwargs)
See the guide: Layers (contrib) > Higher level ops for building neural network layers
Adds a fully connected layer.
fully_connected
creates a variable called weights
, representing a fully connected weight matrix, which is multiplied by the inputs
to produce a Tensor
of hidden units. If a normalizer_fn
is provided (such as batch_norm
), it is then applied. Otherwise, if normalizer_fn
is None and a biases_initializer
is provided then a biases
variable would be created and added the hidden units. Finally, if activation_fn
is not None
, it is applied to the hidden units as well.
Note: that ifinputs
have a rank greater than 2, theninputs
is flattened prior to the initial matrix multiply byweights
.
inputs
: A tensor of with at least rank 2 and value for the last dimension, i.e. [batch_size, depth]
, [None, None, None, channels]
.num_outputs
: Integer or long, the number of output units in the layer.activation_fn
: activation function, set to None to skip it and maintain a linear activation.normalizer_fn
: normalization function to use instead of biases
. If normalizer_fn
is provided then biases_initializer
and biases_regularizer
are ignored and biases
are not created nor added. default set to None for no normalizer functionnormalizer_params
: normalization function parameters.weights_initializer
: An initializer for the weights.weights_regularizer
: Optional regularizer for the weights.biases_initializer
: An initializer for the biases. If None skip biases.biases_regularizer
: Optional regularizer for the biases.reuse
: whether or not the layer and its variables should be reused. To be able to reuse the layer scope must be given.variables_collections
: Optional list of collections for all the variables or a dictionary containing a different list of collections per variable.outputs_collections
: collection to add the outputs.trainable
: If True
also add variables to the graph collection GraphKeys.TRAINABLE_VARIABLES
(see tf.Variable).scope
: Optional scope for variable_scope.The tensor variable representing the result of the series of operations.
ValueError
: if x has rank less than 2 or if its last dimension is not set.Defined in tensorflow/contrib/framework/python/ops/arg_scope.py
.
© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/contrib/layers/fully_connected