ValueError: Cannot feed value of shape (1,) for Tensor u'Placeholder:0', which has shape '(1, 1)'
来源:互联网 发布:2016人工智能论坛 编辑:程序博客网 时间:2024/06/05 06:41
这里x_,y_是两个数字,当我运行时
sess.run(train_op , feed_dict = {x_data:np.array([x_]) , y_data:np.array([y_])})
遇到了
Traceback (most recent call last):
File “linear.py”, line 71, in
y_data:np.array([y_])})
File “/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py”, line 889, in run
run_metadata_ptr)
File “/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py”, line 1096, in _run
% (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (1,) for Tensor u’Placeholder:0’, which has shape ‘(1, 1)’
其实原因很简单,我这里的feed需要(1,1)的矩阵,也就是一维的且只有一个元素的矩阵,但[x_]和[y_]在tensorflow里会被认为是一维的但元素个数不知。
因为在给函数传参数shape时需要传递形状,如shape=[2,2],表示2维矩阵,每个维度有两个元素,只是代表形状,不是具体的矩阵
当传递给feed里面的占位符时,需要实际具体的矩阵而不是形状,如传二维的矩阵:x_data:[[1,1],[1,1]]
总之形状和实际具体矩阵不要弄混
- ValueError: Cannot feed value of shape (1,) for Tensor u'Placeholder:0', which has shape '(1, 1)'
- ValueError: Cannot feed value of shape (64, 10) for Tensor u'Placeholder_1:0', whichhas shape '(10,
- ValueError: Shape must be rank 0 but is rank 1 for 'train_data/ReadFile' (op: 'ReadFile') with input
- TensorBoard报错:InvalidArgumentError: You must feed a value for placeholder tensor 'inputs/x_input' wi
- Shape of HDU 7.1.1
- 创建dataframe并插入一行时报错:ValueError: Shape of passed values is (1, X), indices imply (X, X)
- ValueError: could not broadcast input array from shape (300,2,300,1) into shape (300,2,1,1)
- ValueError: The hardcoded shape for thenumber of rows in the filter (5) isn't the run time shape (6)
- InvalidArgumentError (see above for traceback): Shape [-1,-1] has negative d
- Shape Signature(1)
- AsTensorError: ('Cannot convert Tensor("mul:0", shape=(19, 19, 5, 80), dtype=float32) to TensorType'
- Check failed: axis_index < num_axes() (1 vs. 1) axis 1 out of range for 1-D Blob with shape
- Implicit Shape Model(1)
- YTU 2915: Shape系列-1
- numpy函数:[1]shape用法
- [YTU]_2915(Shape系列-1)
- OOM when allocating tensor with shape
- 取得tensor里的shape操作
- git创建版本库
- 简化路径-LintCode
- Java基础:List接口中特有方法\LinkedList
- 堆和栈的笔记
- 职业转型的终极指南:从新手到专业的机器学习工程师
- ValueError: Cannot feed value of shape (1,) for Tensor u'Placeholder:0', which has shape '(1, 1)'
- 装配一个对象 dataSource 对象 spring 火推03
- PC浏览器播放m3u8
- K分类算法
- 面向对象编程有三大特性:封装、继承、多态。
- POJ2299 线段树求逆序数
- Qt组件之模拟电池充电
- git拉一个新分支
- 线性表类型定义与顺序表操作