当前位置:网站首页>【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})
边栏推荐
猜你喜欢
CVE-2020-27986 (Sonarqube sensitive information leak) vulnerability fix
Some impressions of the 519 plummet 2021-05-21
Diodes and their applications
配置zabbix自动发现和自动注册。
苏州大学:从 PostgreSQL 到 TDengine
鲲鹏devkit & boostkit
How to do short video food from the media?5 steps to teach you to get started quickly
Differences and concepts between software testing and hardware testing
第二届中国Rust开发者大会(RustChinaConf 2021~2022)线上大会正式开启报名
k8s之KubeSphere部署有状态数据库中间件服务 mysql、redis、mongo
随机推荐
面试官:可以谈谈乐观锁和悲观锁吗
腾讯安全游戏行业研讨会:生态共建,护航游戏产业健康发展
What is the difference between web testing and app testing?
世界上最大的开源基金会 Apache 是如何运作的?
RKMPP 在FFmpeg上实现硬编解码
第二讲 软件生命周期
HALCON: 对象(object)从声明(declaration)到结束(finalization)
hsql是什么_MQL语言
史上最全!47个“数字化转型”常见术语合集,看完秒懂~
文件加密软件有哪些?保障你的文件安全
Embedded system driver primary [2] - based on character device driver _ basic framework
不精确微分/不完全微分(Inexact differential/Imperfect differential)
[C language] Analysis of function recursion (2)
【Tensorflow】AttributeError: ‘_TfDeviceCaptureOp‘ object has no attribute ‘_set_device_from_string‘
SQL函数 TRUNCATE
Object detection scene SSD-Mobilenetv1-FPN
Interviewer: Can you talk about optimistic locking and pessimistic locking?
好用的php空间,推荐国内三个优质的免费PHP空间[通俗易懂]
【Tensorflow】AttributeError: module ‘keras.backend‘ has no attribute ‘tf‘
Shell脚本完成pxe装机配置