当前位置:网站首页>【Tensorflow】AttributeError: module 'keras.backend' has no attribute 'tf'
【Tensorflow】AttributeError: module 'keras.backend' has no attribute 'tf'
2022-08-02 14:01:00 【there2belief】
Question:
The following pseudocode works fine with keras 2.2.4, but an error occurs with keras 2.3.1:
AttributeError: module 'keras.backend' has no attribute 'tf'
Code:
import tensorflow as tfimport kerastf_backend = keras.backend.tfmodel = keras.models.model_from_json(json_str, custom_objects={'swish':swish, 'backend':keras.backend, 'tf':tf_backend})
Resolve:
The reason for the error is that there is no keras.backend.tf method in keras 2.3.1. At this time, tf can be used instead of keras.backend.tf. The above code can be updated to:
import tensorflow as tfimport kerasif keras.__version__ == "2.2.4":tf_backend = keras.backend.tfelse:tf_backend = tfmodel = keras.models.model_from_json(json_str, custom_objects={'swish':swish, 'backend':keras.backend, 'tf':tf_backend})
边栏推荐
- 苏州大学:从 PostgreSQL 到 TDengine
- Flutter 实现光影变换的立体旋转效果
- 不精确微分/不完全微分(Inexact differential/Imperfect differential)
- CSDN(成长一夏竞赛)- 最大数
- Reading IDEO, Design Changes Everything
- FreeBSD bnxt以太网驱动源码阅读记录三:
- HALCON: 对象(object)从声明(declaration)到结束(finalization)
- els strip collision deformation judgment
- 第二届中国Rust开发者大会(RustChinaConf 2021~2022)线上大会正式开启报名
- Awesome!Alibaba interview reference guide (Songshan version) open source sharing, programmer interview must brush
猜你喜欢
拯救流浪猫 | 「喵先锋」系列数字版权盲盒明日开抢
Summer training camp-week2 graph theory
【C语言】细品分支结构——switch语句
Supervision strikes again, what about the market outlook?2021-05-22
Break the limit of file locks and use storage power to help enterprises grow new momentum
stack && queue
uview 2.x版本 tabbar在uniapp小程序里头点击两次才能选中图标
科研试剂DSPE-PEG-VIP,二硬脂酰基磷脂酰乙醇胺-聚乙二醇-血管活性肠肽VIP
网络安全第六次作业
巴比特 | 元宇宙每日必读:蒂芙尼宣布推出限量版 CryptoPunk 定制吊坠
随机推荐
Detailed explanation of stored procedures
Detailed explanation of ORACLE expdp/impdp
static修饰的函数有什么特点(static可以修饰所有的变量吗)
SQL函数 USER
乐心湖‘s Blog——MySQL入门到精通 —— 囊括 MySQL 入门 以及 SQL 语句优化 —— 索引原理 —— 性能分析 —— 存储引擎特点以及选择 —— 面试题
leetcode 504. Base 7 七进制数 (简单)
vim复制粘贴_vim如何复制粘贴
RKMPP API安装使用总结
requestparam注解接的收的是什么格式(玄机赋注解)
基于深度学习的图像检索方法!
删除链表的节点
数值的整数次方
好用的php空间,推荐国内三个优质的免费PHP空间[通俗易懂]
网络安全第一次作业(2)
els 长条方块变形条件、边界碰撞判定
网络安全第五次作业
二分查找 && 树
【学习笔记】数位dp
Gstreamer Plugin注册流程详解
【ONE·Data || Getting Started with Sorting】