TypeError: Fetch argument 0.484375 has invalid type <class 'numpy.float32'>, must be a string or Tensor. (Can not convert a float32 into a Tensor or Operation.)
报错:
TypeError: Fetch argument 0.484375 has invalid type <class 'numpy.float32'>, must be a string or Tensor. (Can not convert a float32 into a Tensor or Operation.)
出错代码:
_, summaries, acc, loss = sess.run([train_step, train_summary_op, acc, cost], feed_dict={cnn.input_x1: x1, cnn.input_x2: x2, cnn.input_y: y, cnn.dropout_keep_prob: 0.5})
time_str = datetime.datetime.now().isoformat()
print("{}: loss {:g}, acc {:g}".format(time_str, loss, acc))
原因:
代码迭代了n次,第1次迭代可以打印出acc的值,第2次迭代就开始报错误。主要是因为在同一个session里面用新的acc取代了原来的acc, 第1次迭代时,两个变量都是原始数据,数据类型均为Tensor。但run之后,原来的acc就被新的acc取代了,此时两个变量的数据类型都变成了numpy.float32,所有第2次迭代的时候就会因为数据类型不是Tensor而报错。
解决方法:
避免重名引起数据类型输送错误,最好使用不同的命名。
_, summaries, accuracy, loss = sess.run([train_step, train_summary_op, acc, cost], feed_dict={cnn.input_x1: x1, cnn.input_x2: x2, cnn.input_y: y, cnn.dropout_keep_prob: 0.5})
time_str = datetime.datetime.now().isoformat()
print("{}: loss {:g}, acc {:g}".format(time_str, loss, accuracy))
TypeError: Fetch argument 0.484375 has invalid type <class 'numpy.float32'>, must be a string or Tensor. (Can not convert a float32 into a Tensor or Operation.)的更多相关文章
- TypeError: Fetch argument 0 has invalid type <type 'int'>, must be a string or Tensor. (Can not convert a int into a Tensor or Operation.)
6月5日的時候,修改dilated_seg.py(使用tensorflow)出現了報錯: TypeError: Fetch argument 0 has invalid type <type ' ...
- has invalid type <class 'numpy.ndarray'>, must be a string or Tensor
转自: https://blog.csdn.net/jacke121/article/details/78833922 has invalid type <class 'numpy.ndarra ...
- TypeError: Fetch argument None has invalid type <type 'NoneType'>
(fetch, type(fetch)))TypeError: Fetch argument None has invalid type <type 'NoneType'> 我的解决方案是 ...
- 记录:tensoflow改错TypeError: Cannot interpret feed_dict key as Tensor: Can not convert a float into a Te
错误描述: TypeError: Cannot interpret feed_dict key as Tensor: Can not convert a float into a Tensor. 改错 ...
- python运行出现TypeError: super() takes at least 1 argument (0 given)错误
在写继承子类的时候出现了TypeError: super() takes at least 1 argument (0 given)的error: 源代码(python3中完美可运行): class ...
- vue.esm.js?efeb:628 [Vue warn]: Invalid prop: type check failed for prop "defaultActive". Expected String with value "0", got Number with value 0.
vue.esm.js?efeb:628 [Vue warn]: Invalid prop: type check failed for prop "defaultActive". ...
- Python super(Todo,self).__init__() TypeError: super() argument 1 must be type, not classobj
示例如下 class A(): def __init__(self):pass class B(A): def __init__(self): super(A, self).__init__() 当调 ...
- 使用==操作符比较命令行参数args[0]和字符串返回“Invalid type"
运行程序接收一个来自命令行的字符串参数(取值1,2,3,4),根据参数执行对应语句块. 由于未能判断字符串内容是否相同导致代码if语句块代码失效,怎么也看不到schedule方法的效果, 以下是错误代 ...
- statsmodels.tsa.arima_model预测时报错TypeError: int() argument must be a string, a bytes-like object or a number, not 'Timestamp'
在 python 中用 statsmodels创建 ARIMA 模型进行预测时间序列: import pandas as pd import statsmodels.api as sm df = pd ...
随机推荐
- 常用Mysql或者PostGresql或者Greenplum的语句总结。
1.使用mysql的union all可以同时查询出所有自己想要查询数据表的数据量. select 'user' as tablename, count(*) from user union all ...
- PHP unicode与普通字符串的相互转化
unicode转字符串 方法一:json /** * unicode转字符串,通过json转化 * @param $str * @return string */ function unicode_d ...
- Git基本操作指令
Git是世界上目前最先进的分布式版本控制系统. 工作原理图: Workspace工作区,Index暂存区,Repository本地仓库区,Remote远程仓库. SVN与Git的最主要的区别? SVN ...
- js下载base64格式的图片(兼容火狐)
//下载图片 download() { let imgData = 'data:image/png;base64,iVBORw0KGgoAAAANSUh........'; this.download ...
- 多线程处理list
package com.zhx.web.invoice.service; import java.util.*; import java.util.concurrent.Callable; impor ...
- webpack的devServer配置错误
首先声明,之前vue项目没有报错,做react项目这样配置就报错了. 一.问题描述 [HMR] Hot Module Replacement is disabled. 二.问题分析 不太理解控制台为什 ...
- CodeForces - 1013C C - Photo of The Sky 贪心
题目链接: https://vjudge.net/problem/1735276/origin 题目大意与思路: 题目的基本意思就是求一个矩形的最小面积. 这个可以用最大最小值, 将他们分为X和Y组. ...
- django——模型层之多表操作
django的多表操作 1.使用场景 在实际生产过程多,我们面对的数据纷繁复杂,此时就需要良好的数据结构设计,多表之间的约束关系为我们提供了数据管理以及查询的便利.在MYsql中我们利用外键(fore ...
- lArea.js 城市选择
http://blog.csdn.net/libin_1/article/details/50689075 lArea.js
- CSS3_伸缩盒模型_弹性布局_等分布局_flex 布局
伸缩盒模型 CSS3 引入的布局模式 Flexbox 布局 主要思想: 让容器有能力让其子项目能够改变其宽度,高度,以最佳方式填充可用空间. 特点: display: flex; 只能控制其子元 ...