python - 如何将张量转换为numpy数组matmul的结果
问题描述
我想将 fc1 张量转换为 numpy 数组。如何得到它?
fc1 = tf.reshape(conv1, [-1, weights['wd1'].get_shape().as_list()[0]])
fc1 = tf.matmul(fc1, weights['wd1'])
解决方案
它会导致此错误
fc1 = tf.reshape(conv1, [-1, weights['wd1'].get_shape().as_list()[0]])
fc1 = tf.matmul(fc1, weights['wd1'])
sess = tf.Session()
fc1.eval(session=sess)
Traceback (most recent call last):
File "C:/Users/ybrot/OneDrive/바탕 화면/QCNN/QCNN.py", line 150, in <module>
logits = conv_net(X, weights, keep_prob)
File "C:/Users/ybrot/OneDrive/바탕 화면/QCNN/QCNN.py", line 114, in conv_net
fc1.eval(session=sess)
File "C:\Users\ybrot\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 731, in eval
return _eval_using_default_session(self, feed_dict, self.graph, session)
File "C:\Users\ybrot\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 5579, in _eval_using_default_session
return session.run(tensors, feed_dict)
File "C:\Users\ybrot\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 950, in run
run_metadata_ptr)
File "C:\Users\ybrot\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1173, in _run
feed_dict_tensor, options, run_metadata)
File "C:\Users\ybrot\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1350, in _do_run
run_metadata)
File "C:\Users\ybrot\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1370, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found.
(0) Invalid argument: You must feed a value for placeholder tensor 'Placeholder' with dtype float and shape [?,256]
[[node Placeholder (defined at /Users/ybrot/OneDrive/바탕 화면/QCNN/QCNN.py:54) ]]
[[MatMul/_1]]
(1) Invalid argument: You must feed a value for placeholder tensor 'Placeholder' with dtype float and shape [?,256]
[[node Placeholder (defined at /Users/ybrot/OneDrive/바탕 화면/QCNN/QCNN.py:54) ]]
0 successful operations.
0 derived errors ignored.
推荐阅读
- dapr - 如何在 Ubuntu Linux 上安装 Dapr
- macos - 多个版本的gnuplot
- php - 为带有确认数组的 foreach() 提供的参数无效
- javascript - 如何在 React 中渲染动态表单
- c++ - 如果偶数浮点数(小数)是 2 的模数,那么它不会给出 '0' 作为结果!在 C++ 中
- c# - 如何修剪网址?
- python - 如何从二维数组中绘制特定值的极坐标图?
- php - 使用 PHP 按扩展类型强制下载文件
- vue.js - 如果对象的属性,VueJS 不会更新组件中的存储值
- selenium-webdriver - 如何在 selenium 中编写 Select 语句