use*_*352 2 python tensorflow activation-function
我有一段代码使用Sigmoid激活函数进行分类,以输出[0,1]。但是我需要一个激活函数来输出0或1的二进制值。
x = tf.placeholder("float", [None, COLUMN])
Wh = tf.Variable(tf.random_normal([COLUMN, UNITS_OF_HIDDEN_LAYER], mean=0.0, stddev=0.05))
h = tf.nn.sigmoid(tf.matmul(x, Wh))
Wo = tf.Variable(tf.random_normal([UNITS_OF_HIDDEN_LAYER, COLUMN], mean=0.0, stddev=0.05))
y = tf.nn.sigmoid(tf.matmul(h, Wo))
# Objective functions
y_ = tf.placeholder("float", [None, COLUMN])
correct_prediction = tf.equal(tf.argmax(y, 1),tf.argmax(y, 1))
cost = tf.reduce_sum(tf.cast(correct_prediction, "float"))/BATCH_SIZE
Run Code Online (Sandbox Code Playgroud)
您能告诉我如何用二进制第一步代替Sigmoid函数吗?
| 归档时间: |
|
| 查看次数: |
4112 次 |
| 最近记录: |