python - 调用 keras 模型 train_on_batch 时,“张量必须来自与张量相同的图”
问题描述
gen_examples = self.generator.predict([xmal_batch, noise])
生成器是一个 keras 模型,它向原始数据添加噪声并生成新示例
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
sess.run(tf.local_variables_initializer())
saver.restore(sess, PATH)
print ("load model from:", PATH)
ymal_batch = sess.run(model.y_pred, feed_dict = {model.x_input: gen_examples})
self.substitute_detector.train_on_batch(gen_examples, ymal_batch)
ValueError: Tensor("training/Adam/Const:0", shape=(), dtype=int64) 必须与 Tensor("Adam/iterations:0", shape=(), dtype=resource) 来自同一个图。
我是 Tensorflow 的新手,我不知道为什么会出现这个错误,因为gen_examples
并且ymal_batch
基本上是 numpy 数组。
似乎创建了新图表,但我很困惑。
解决方案
推荐阅读
- git - 每次我需要添加库时
- performance - 找到 N 个最近的海龟的最有效方法是什么?
- excel - 将数据粘贴到多个单元格并使用循环时键入 Mismatch VBA
- java - 根据 Gradle 文件中的配置文件区分依赖关系
- winapi - 从 C#/F# 使用 IColumnManager 获取/设置列
- git - Github 拉取请求显示错误的差异
- python - 如何使用 curl 将文件上传到 dict 类型内的 python-eve 字段
- javascript - 将 db 值传递给模态框
- spring-boot - Spring Boot 休息控制器测试
- sql - 不使用导出向导从 SQL 导出到 MS-Access