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 ...
随机推荐
- 学习笔记: yield迭代器
yield 与 IEnumerable<T> 结对出现, 可实现按需获取 , 迭代器模式 static void Main(string[] args) { ...
- 安全体系(一)—— DES算法详解
本文主要介绍了DES算法的步骤,包括IP置换.密钥置换.E扩展置换.S盒代替.P盒置换和末置换. 安全体系(零)—— 加解密算法.消息摘要.消息认证技术.数字签名与公钥证书 安全体系(二)——RSA算 ...
- C# 数据为空,不能对NULL调用此方法或属性的解决办法
在运行C#项目时,报出了以下错误,错误原因是数据库中的值为null时,查询时会触发该错误提示 部分源代码如下: public List<Student> findData2() { ; / ...
- C# Winform控件 - Form
一.Form窗体样式 1.FormBorderStyle (1)None (2)FixedSingle (3)Fixed3D 个人感觉跟Fixedsingle区别不大 (4)FixedDialog 不 ...
- Hibernate 双向一对多映射
附代码: public class Order { private Integer id; private String OrderName; private Customer customer; p ...
- JS基础学习2
1.CMAScript 运算符 算数运算符 递增(++).递减(--) var i=15; console.log(i++); console.log(i); var i1=15; console.l ...
- ElasticSearch + Canal 开发千万级的实时搜索系统
公司是做社交相关产品的,社交类产品对搜索功能需求要求就比较高,需要根据用户城市.用户ID昵称等进行搜索. 项目原先的搜索接口采用SQL查询的方式实现,数据库表采用了按城市分表的方式.但随着业务的发展, ...
- Java 初始化、final、清理
1 为什么需要无参构造器? 第一个是继承需要 super 调用父类的构造器(父类构造器必须存在且不为 private.可以是无参/默认构造器,也可以是有参构造器),特别的如果父类不包含无参构造器的话, ...
- Python 在cmd中import模块成功,但是在jupyter notebook中No module xxx found
由于需要用到python中的某个库,因此打开命令行窗口cmd,然后使用pip安装.安装成功后,在cmd中输入python调出python环境,import该模块并使用,可以正常使用.但是打开juypt ...
- C++接口与实现的抽象分离
IPerson.h #ifndef I_PERSON_H_ #define I_PERSON_H_ #include <string> #include <ostream> c ...