相关疑难解决方法(0)

如何喂养占位符?

我正在尝试实现一个简单的前馈网络.但是,我无法弄清楚如何喂养Placeholder.这个例子:

import tensorflow as tf

num_input  = 2
num_hidden = 3
num_output = 2

x  = tf.placeholder("float", [num_input, 1])
W_hidden = tf.Variable(tf.zeros([num_hidden, num_input]))
W_out    = tf.Variable(tf.zeros([num_output, num_hidden]))
b_hidden = tf.Variable(tf.zeros([num_hidden]))
b_out    = tf.Variable(tf.zeros([num_output]))

h = tf.nn.softmax(tf.matmul(W_hidden,x) + b_hidden)

sess = tf.Session()

with sess.as_default():
    print h.eval()
Run Code Online (Sandbox Code Playgroud)

给我以下错误:

  ...
    results = self._do_run(target_list, unique_fetch_targets, feed_dict_string)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 419, in _do_run
    e.code)
tensorflow.python.framework.errors.InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder' with dtype float and shape dim { size: 2 …
Run Code Online (Sandbox Code Playgroud)

python tensorflow

19
推荐指数
1
解决办法
3万
查看次数

标签 统计

python ×1

tensorflow ×1