Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are tf.layers.dense() and tf.contrib.layers.fully_connected() interchangeable?

Tags:

tensorflow

I am used to using tf.contrib.layers.fully_connected to build a fully connected layer. Recently I ran into tf.layers.dense apparently used where the first functioned could be used. Are the interchangeable, producing the same output?

like image 933
Conner M. Avatar asked Jul 04 '17 18:07

Conner M.


People also ask

What does TF keras layers dense () do?

This function is used to create fully connected layers, in which every output depends on every input. Parameters: This function takes the args object as a parameter which can have the following properties: units: It is a positive number that defines the dimensionality of the output space.

What is Tensorflow layer dense?

Dense layer is the regular deeply connected neural network layer. It is most common and frequently used layer. Dense layer does the below operation on the input and return the output. output = activation(dot(input, kernel) + bias)

What is dense layer?

In any neural network, a dense layer is a layer that is deeply connected with its preceding layer which means the neurons of the layer are connected to every neuron of its preceding layer. This layer is the most commonly used layer in artificial neural network networks.

What is a fully connected layer in keras?

Fully connected layers are defined using the Dense class. You can specify the number of neurons or nodes in the layer as the first argument and the activation function using the activation argument.


1 Answers

They are essentially the same, the later calling the former.

However tf.contrib.fully_connected adds a few functionalities on top of dense, in particular the possibility to pass a normalization and an activation in the parameters, à la Keras. As noted by @wordforthewise, mind that the later defaults to tf.nn.relu.

More generally, the TF API proposes (and mixes somewhat confusingly) low- and hi-level APIs; more on that here.

like image 91
P-Gn Avatar answered Oct 07 '22 07:10

P-Gn