Tensorflow图层Api线性激活功能

Dav*_*ook 2 python tensorflow

这个问题类似于这个问题:如何在TensorFlow中使用线性激活函数?但不一样.

在最后的密集层上,我想输出28个带有线性激活的节点,而不是sigmoid.我正在使用新的图层api,如下所示:https://www.tensorflow.org/tutorials/layers

我的最终图层堆栈看起来像这样:

flat = tf.reshape(pool3, [-1, 128 * 128 * 128]) #width (after poolings), height (after poolings), filters
dense1 = tf.layers.dense(inputs=flat, units=4096, activation=tf.nn.relu)
dense2 = tf.layers.dense(inputs=dense1, units=4096, activation=tf.nn.relu)
dropout = tf.layers.dropout(
            inputs=dense2, rate=0.4, training=mode == learn.ModeKeys.TRAIN)
output = tf.layers.dense(inputs=dropout, units=28)
Run Code Online (Sandbox Code Playgroud)

如何确保28个节点的输出实际上是线性的?在CNTK中,您将激活函数指定为None(请参见此处:图层中的cntk线性激活函数?)

指针非常感谢.谢谢!

int*_*jay 6

关于参数的说明文件denseactivation:

activation:激活功能(可调用).将其设置为"无"以保持线性激活.

None 是默认值,因此不指定激活将其设置为线性.