0
代碼:如何初始化slim.fully_connected變量?
tf.reset_default_graph()
init = tf.global_variables_initializer()
with tf.Session() as sess:
states = np.array(range(3))
oneh = slim.one_hot_encoding(states, len(states))
x = slim.fully_connected(oneh,2, \
biases_initializer=None,activation_fn=tf.nn.sigmoid,weights_initializer=tf.ones_initializer())
sess.run(init)
print(sess.run(x))
例外:
FailedPreconditionError (see above for traceback): Attempting to use uninitialized value fully_connected/weights
[[Node: fully_connected/weights/read = Identity[T=DT_FLOAT, _class=["loc:@fully_connected/weights"], _device="/job:localhost/replica:0/task:0/cpu:0"](fully_connected/weights)]]