AttributeError: Layer my_model has no inbound nodes.
记录一下model.output的一个坑
官方推荐了两种实例化model的方式
这个坑大多数是用了第二种方式才会出现
试一下第一种就不会
1 - With the “Functional API”, where you start from Input
,
you chain layer calls to specify the model’s forward pass,
and finally you create your model from inputs and outputs:
import tensorflow as tfinputs = tf.keras.Input(shape=(3,))
x = tf.keras.layers.Dense(4, activation=tf.nn.relu)(inputs)
outputs = tf.keras.layers.Dense(5, activation=tf.nn.softmax)(x)
model = tf.keras.Model(inputs=inputs, outputs=outputs)
Note: Only dicts, lists, and tuples of input tensors are supported. Nested
inputs are not supported (e.g. lists of list or dicts of dict).
2 - By subclassing the Model
class: in that case, you should define your
layers in __init__
and you should implement the model’s forward pass
in call
.
import tensorflow as tfclass MyModel(tf.keras.Model):def __init__(self):super(MyModel, self).__init__()self.dense1 = tf.keras.layers.Dense(4, activation=tf.nn.relu)self.dense2 = tf.keras.layers.Dense(5, activation=tf.nn.softmax)def call(self, inputs):x = self.dense1(inputs)return self.dense2(x)model = MyModel()
AttributeError: Layer my_model has no inbound nodes.相关推荐
- Keras functional API快速入门
2019独角兽企业重金招聘Python工程师标准>>> Keras functional API快速入门 The Keras functional API is the way to ...
- Keras学习笔记:函数式模型
目录: 目录: 函数式(Functional)模型 第一个模型:全连接网络 多输入和多输出模型 让我们用函数式模型来实现这个框图 共享层 更多的例子 inception模型 卷积层的残差连接 共享视觉 ...
- stream_kws_cnn
文章目录 0x00 parser 超参传入 0x01 数据预处理 0x02 model 此处选择 CNN 2.1 输入( 此处 flags.preprocess = mfcc) 2.2 输入增维 2. ...
- GraphSAGE NIPS 2017 代码分析(Tensorflow版)
文章目录 数据集 ppi数据集信息 toy-ppi-G.json 图的信息 toy-ppi-class_map.json toy-ppi-id_map.json toy-ppi-walks.txt t ...
- HNSW算法原理(二)之删除结点
原文:https://blog.csdn.net/CHIERYU/article/details/86647014 HNSW算法原理(二)之删除结点 本篇文章继之前的一篇文章 HNSW算法原理(一) ...
- tf keras SimpleRNN源码解析
环境 package version tensorflow 2.3.0 keras 2.4.3 源码 部分主要源码 class RNN(Layer):def __init__(self,cell,re ...
- 05_专家的快速入门、加载MNIST数据集、数据集切分和混淆、定义类的方式构建模型、选择优化器和损失函数、训练模型和测试模型准确率
https://tensorflow.google.cn/tutorials/quickstart/advanced 导入TensorFlow到你的程序中: import tensorflow as ...
- alexnet 结构_AlexNet的体系结构和实现
alexnet 结构 In my last blog, I gave a detailed explanation of the LeNet-5 architecture. In this blog, ...
- GaussDB(for MySQL)如何在存储架构设计上做到高可靠、高可用
摘要: GaussDB(for MySQL)通过ND算子下推解决存储节点和计算节点之间的传输速度,减少网络开销这个难题. 数据库作为高效稳定处理海量数据交易/分析的坚强数据底座,底层架构设计的重要性不 ...
最新文章
- iCup,USB加热饮品方案
- Thinkphp5+PHPExcel实现批量上传表格数据
- Dell在CRM的创新及该模式的推广
- 图形处理(一)离散指数映射参数化-Siggraph 2006
- 倡导农民丰收节交易会-农业大健康·万祥军:谋定功能性农业
- java中使用lua脚本
- matlab中符号对象的数据类型是,符号对象(Symbolic Object)的使用
- 波兰加密矿企GamerHash计划在韩国建立业务
- javascript中的滚动到顶部和Scroll有关的方法
- 不需编译让aspx页自主筛选数据绑定记录
- WinAVI FLV Converter v1.0 注册码
- 手机android安装程序,Android手机程序安装指南
- php 速卖通产品采集,AliExpress(速卖通)关键词搜索结果采集 - 八爪鱼采集器
- 华为手机灵敏度设置_和平精英华为手机灵敏度怎么设置 上分灵敏度推荐
- The Crime-solving Plan of Groundhog
- Java - Certificate has been revoked
- C#大恒相机采集图片时图片上下对称折叠了
- Pytorch版本过高产生的RuntimeError: Legacy autograd function with non-static forward method is deprecated.
- C/C++ 中 exit() 函数
- layui表格 设置默认排序_改造 layui 表格组件实现多重排序
热门文章
- 浅论定点DSP与浮点DSP的区别
- wo de wen jian
- android 8 zuk,ZUK Z2正式升级安卓8.0,老用户感动
- 上传图片预览(服务器版)组件
- Centos7使用Docker部署Chemex资产管理系统
- 平台篇-八年磨一剑,重新定义 HBase——HBase 2.0阿里云 HBase 解读...
- 【历史上的今天】9 月 15 日:华为诞生;Stack Overflow 网站公开测试;计算机协会成立
- 解决最新版discuz安装模板插件提示“对不起,您安装的不是正版应用”
- 查询注册表的命令行工具reg
- English Proverbs