2017-07-11 34 views
0

我用於卷積神經網絡下面的代碼在以下鏈接:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3_NeuralNetworks/convolutional_network.py和我想設定的參數爲我的模型:如何設置CNNs TensorFlow中的網絡權重?

我的輸入是35 * 128

一個陣列我設置以下網絡參數:

# Network Parameters 
n_input = 35*128 
n_classes = 6 
dropout = 0.75 

請問我可以讓我知道如何設置權重和偏差?默認值爲:

# Store layers weight & bias 
weights = { 
    # 5x5 conv, 1 input, 32 outputs 
    'wc1': tf.Variable(tf.random_normal([5, 5, 1, 32])), 
    # 5x5 conv, 32 inputs, 64 outputs 
    'wc2': tf.Variable(tf.random_normal([5, 5, 32, 64])), 
    # fully connected, 7*7*64 inputs, 1024 outputs 
    'wd1': tf.Variable(tf.random_normal([7*7*64, 1024])), 
    # 1024 inputs, 10 outputs (class prediction) 
    'out': tf.Variable(tf.random_normal([1024, n_classes])) 
} 

biases = { 
    'bc1': tf.Variable(tf.random_normal([32])), 
    'bc2': tf.Variable(tf.random_normal([64])), 
    'bd1': tf.Variable(tf.random_normal([1024])), 
    'out': tf.Variable(tf.random_normal([n_classes])) 
} 
+0

您已經使用正態隨機分佈的值對它們進行了初始化。 'tf.random_normal()'照顧初始化 – Sriram

回答

0

終於我發現我的溶液通過讀取tensorflow以下教程是真正有用的:

https://www.tensorflow.org/tutorials/layers

我的輸入圖像大小爲35×128和我應爲我設置在緻密層參數('WD1 ')到9 * 32 * 64。

'wd1': tf.Variable(tf.random_normal([9*32*64, 1024])) 
1

我沒有足夠的知名度評論。所以只需明確指出你的意思是設定的重量和偏差。如果您想要設置某個標準的值,請參閱此鏈接https://www.tensorflow.org/api_docs/python/tf/random_normal

在此,您可以指定權重和偏差值的平均值,標準偏差和dtype。

+0

我對隨機正常函數很熟悉,但是我的問題是,如何根據我的輸入數據設置權重和偏差的大小 – MSN

+0

這是否意味着您要將形狀作爲變量?你不想硬編碼形狀,對吧? – Akhilesh