Is tf.layers.dense a single layer?

后端 未结 2 1096
囚心锁ツ
囚心锁ツ 2021-02-07 10:04

If I just use a single layer like this:

layer = tf.layers.dense(tf_x, 1, tf.nn.relu)

Is this just a single layer with a single node?

Or

2条回答
  •  我寻月下人不归
    2021-02-07 10:25

    tf.layers.dense adds a single layer to your network. The second argument is the number of neurons/nodes of the layer. For example:

    # no hidden layers, dimension output layer = 1
    output = tf.layers.dense(tf_x, 1, tf.nn.relu)
    
    # one hidden layer, dimension hidden layer = 10,  dimension output layer = 1
    hidden = tf.layers.dense(tf_x, 10, tf.nn.relu)
    output = tf.layers.dense(hidden, 1, tf.nn.relu)
    

    My network seemed to work properly with just 1 layer, so I was curious about the setup.

    That is possible, for some tasks you will get decent results without hidden layers.

提交回复
热议问题