我想在張量流中使用maxout激活函數,但我不知道應該使用哪個函數。如何在張量流中使用maxout激活函數?
0
A
回答
1
我不認爲有一個最大激活,但沒有什麼能阻止你自己做出來。你可以做如下的事情。
with tf.variable_scope('maxout'):
layer_input = ...
layer_output = None
for i in range(n_maxouts):
W = tf.get_variable('W_%d' % d, (n_input, n_output))
b = tf.get_variable('b_%d' % i, (n_output,))
y = tf.matmul(layer_input, W) + b
if layer_output is None:
layer_output = y
else:
layer_output = tf.maximum(layer_output, y)
注意,這是代碼,我只是在我的瀏覽器中寫道所以有可能是語法錯誤,但你應該得到的總體思路。您只需執行許多線性變換,並在所有變換中取得最大值。
4
我找來MAXOUT拉入請求,這裏是鏈接:
https://github.com/tensorflow/tensorflow/pull/5528
代碼如下:
def maxout(inputs, num_units, axis=None):
shape = inputs.get_shape().as_list()
if axis is None:
# Assume that channel is the last dimension
axis = -1
num_channels = shape[axis]
if num_channels % num_units:
raise ValueError('number of features({}) is not a multiple of num_units({})'
.format(num_channels, num_units))
shape[axis] = -1
shape += [num_channels // num_units]
outputs = tf.reduce_max(tf.reshape(inputs, shape), -1, keep_dims=False)
return outputs
這裏是它如何工作的:
0
這段代碼如何? 這似乎在我的測試中工作。
def max_out(input_tensor,output_size):
shape = input_tensor.get_shape().as_list()
if shape[1] % output_size == 0:
return tf.transpose(tf.reduce_max(tf.split(input_tensor,output_size,1),axis=2))
else:
raise ValueError("Output size or input tensor size is not fine. Please check it. Reminder need be zero.")
我指在the following page的圖。
相關問題
- 1. 如何改變張量流r0.9中DNNClassifier的激活函數?
- 2. 在張量流中應用自己的激活函數
- 3. 張量流中的二元閾值激活函數
- 4. 如何將激活正則化添加到張量流層
- 5. 張量流動中的激活函數有區別嗎? tf.nn.tanh vs tf.tanh
- 6. 如何在張量流中使用tf.losses.log_loss?
- 7. 正確使用張量流STFT函數
- 8. 如何在張量流中使用張量的動態形狀
- 9. 可以使用內置張量函數作爲神經網絡的激活嗎?
- 10. 如何在張量流中設置rmse成本函數
- 11. '激活'藍牙LE能量數據流
- 12. 不能得到簡單的張量流邏輯迴歸程序來使用sigmoid激活函數。
- 13. 如何在張量流中使用不同的損失函數,DNNLinearCombinedClassifier
- 14. 如何在張量流中使用自定義數據集?
- 15. 如何使用張量流中的自定義python函數預取數據
- 16. 如何加入張量流中的張量張量?
- 17. 如何替換張量流中張量的維數?
- 18. NN激活函數
- 19. 不能在pycharm中使用張量流
- 20. 在張量流中使用佔位符
- 21. 張量流中的tf.train.batch_join()函數如何工作?
- 22. 如何在張量流中獲得PI?
- 23. 如何在TensorFlow中用Python創建分段激活函數?
- 24. 張量如何在CIFAR10教程中保存張量流?
- 25. 在張量流中,如何將張量的行重置爲零?
- 26. 如何在張量流中調整張量?
- 27. 如何在張量流中實現RGB圖像張量?
- 28. 如何在張量流中採樣圖像張量
- 29. 如何在張量流中改變三維張量的尺寸?
- 30. 如何在張量流中打印張量形狀?