简体   繁体   English

兼容 Keras 和 Tensorflow 版本

[英]compatible Keras and Tensorflow version

I have a separated training and inference system.我有一个独立的训练和推理系统。 The inference system has tensorflow version 1.8 (yes, I know, it is old, but I have no say on upgrading the system...).推理系统有tensorflow 1.8版(是的,我知道,它很旧,但我对升级系统没有发言权......)。

I am building my model in Keras, then try to convert it to pb model for inferencing.我正在 Keras 中构建我的 model,然后尝试将其转换为 pb model 进行推理。 I have trouble finding the compatible Keras version could work with tensorflow 1.8.我很难找到兼容的 Keras 版本可以与 tensorflow 1.8 一起使用。 I am wondering what's the Keras version for tensorflow 1.8?我想知道 tensorflow 1.8 的 Keras 版本是什么? Thanks!谢谢!

One of my environment has tensorflow==1.8.0 I have checked with print(keras.__version__) and it returns 2.1.5-tf my whole code was:我的一个环境有tensorflow==1.8.0我用print(keras.__version__)检查过它返回 2.1.5-tf 我的整个代码是:

from tensorflow.python import keras
print(keras.__version__)

2.1.5-tf 2.1.5-tf

For me, keras 2.1.6 with Python 3.6 worked for Tensorflow 1.8.对我来说,keras 2.1.6 和 Python 3.6 适用于 Tensorflow 1.8。 Here is the link where I found the version of Keras from.这是我从中找到 Keras 版本的链接

You can, and probably should use the Keras that is in your tensorflow version.您可以并且可能应该使用 tensorflow 版本中的 Keras。

Here is the code:这是代码:

import tensorflow as tf
from tensorflow.python import keras
from tensorflow.python.keras import backend as K

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM