当前位置:网站首页>【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})
边栏推荐
猜你喜欢
【C语言】手撕循环结构 —— while语句
Some impressions of the 519 plummet 2021-05-21
网络安全第四次作业
栈 && 队列
Embedded system driver primary [2] - based on character device driver _ basic framework
FreeBSD bnxt以太网驱动源码阅读记录三:
保姆级教程:写出自己的移动应用和小程序(篇三)
Data Organization---Chapter 6 Diagram---Graph Traversal---Multiple Choice Questions
乐心湖‘s Blog——MySQL入门到精通 —— 囊括 MySQL 入门 以及 SQL 语句优化 —— 索引原理 —— 性能分析 —— 存储引擎特点以及选择 —— 面试题
拯救流浪猫 | 「喵先锋」系列数字版权盲盒明日开抢
随机推荐
【Tensorflow】AttributeError: '_TfDeviceCaptureOp' object has no attribute '_set_device_from_string'
第二讲 软件生命周期
泡利不相容原理适用的空间范围(系统)是多大?
els 长条方块变形条件、边界碰撞判定
【C语言】手撕循环结构 —— for语句
FFmpeg AVPacket详解
监管再次重拳出击,后市如何?2021-05-22
ZABBIX配置邮件报警和微信报警
鲲鹏devkit & boostkit
Differences and concepts between software testing and hardware testing
网络安全第三次作业
删除链表的节点
定了!就在7月30日!
苹果,与Web3 “八字不合”
政策利空对行情没有长期影响,牛市仍将继续 2021-05-19
Geoffery Hinton:深度学习的下一个大事件
C language improvement (3)
Reading IDEO, Design Changes Everything
How to do short video food from the media?5 steps to teach you to get started quickly
面试SQL语句,学会这些就够了!!!