ValueError: Shape must be rank 1 but is rank 0 for 'random_normal_6/RandomStandardNormal' (op: 'RandomStandardNormal') with input shapes: [].
R-Prady opened this issue · comments
getting this error for the code
n_input = 784
n_hidden_1=256
weights={'h1': tf.global_variables_initializer(tf.random_normal(n_input ,n_hidden_1)),
'h2': tf.global_variables_initializer(tf.random_normal(n_hidden_1,n_hidden_2)),
'out': tf.global_variables_initializer(tf.random_normal(n_hidden_2,n_classes))
}
instead of
tf.random_normal(n_input ,n_hidden_1)
use the following (add brackets):
tf.random_normal([n_input ,n_hidden_1])
If I wrote them separated to a single variable ,instead of using dictionary, it won't work and threw an compiling error, like the snippet code below:
n_input = 784
n_classes = 10
n_hidden_layer = 256
hidden_layer_weight = tf.Variable(tf.random_normal([n_input, n_hidden_layer]))
hidden_output = tf.Variable(tf.random_normal([n_hidden_layer, n_classes]))
So , this one could be working.
weights = {
'hidden_layer': tf.Variable(tf.random_normal([n_input, n_hidden_layer])),
'out': tf.Variable(tf.random_normal([n_hidden_layer, n_classes]))
}