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 ...
随机推荐
- Redis高可用技术解决方案总结
一.常见使用方式 Redis的几种常见使用方式包括: Redis单副本: Redis多副本(主从): Redis Sentinel(哨兵): Redis Cluster: Redis自研. 二.各种使 ...
- spark MLlib BasicStatistics 统计学基础
一, jar依赖,jsc创建. package ML.BasicStatistics; import com.google.common.collect.Lists; import org.apach ...
- [OpenCV-Python] OpenCV 中摄像机标定和 3D 重构 部分 VII
部分 VII摄像机标定和 3D 重构 OpenCV-Python 中文教程(搬运)目录 42 摄像机标定 目标 • 学习摄像机畸变以及摄像机的内部参数和外部参数 • 学习找到这些参数,对畸变图像进行修 ...
- 分布式session解决——Spring-data-redis
1.如果没有集成shiro来管理session,可以直接使用spring-session 2.若集成了shiro,需要Spring-data-redis (或 shiro-redis) 3.nginx ...
- GA:利用GA对一元函数进行优化过程,求x∈(0,10)中y的最大值——Jason niu
x = 0:0.01:10; y = x + 10*sin(5*x)+7*cos(4*x); figure plot(x, y) xlabel('independent variable') ylab ...
- Linux 添加到环境变量
在Linux下使用源码安装软件的时候,通常只能在软件安装目录下使用该软件命令,这样太麻烦,我们希望全局使用,可以将软件安装路径添加到系统环境变量里. 添加环境变量有2种方法: 1. 使用export命 ...
- django中widget小部件
1. 处理 input 的部件 TextInput NumberInput EmailInput URLInput PasswordInput HiddenInput DateInput Dat ...
- java之微信支付通知
微信支付,是现在大多数平台都需要接入的一个支付方式,没办法,谁让现在的用户都习惯了这种消费方式呢 我今天只说说微信支付通知,我们后台怎么接收通知,并把我们的订单的状态改为已支付, 至于为什么不说支付的 ...
- git使用习惯
1.每早一更新,提交前更新 git pull -u origin master: master(master为分支名称) 2.每晚一提交: git add . (注:别忘记后面的.此操作是把文件夹下面 ...
- nohup & 及端口查看
ps -aux | grep processName | grep -v grep | awk '{print $2}' a:显示所有程序 u:以用户为主的格式来显示 x:显示所有程序,不以终端机来区 ...