Python 与 tensorflow-gpu 1.4 一起使用的 keras 版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/51856613/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 19:57:01  来源:igfitidea点击:

keras version to use with tensorflow-gpu 1.4

pythontensorflowkerasgpuversion

提问by thebeancounter

I am using ubuntu 16, with python 3, tf-GPU with keras.

我正在使用 ubuntu 16,带有 python 3,带有 keras 的 tf-GPU。

I downgraded to tf 1.4 due to cuda errors as explained here

我降级到TF 1.4由于CUDA错误,说明这里

But now I am getting this error

但现在我收到这个错误

TypeError: softmax() got an unexpected keyword argument 'axis'

类型错误:softmax() 得到了一个意外的关键字参数“轴”

Seems that this is an API changein tensorflow and new keras is not suitable for the old tf.

似乎这是tensorflow中的API变化,新的keras不适用于旧的tf。

I can't find what is the correct keras version to use with tf 1.4 gpu. What is the correct one?

我找不到与 tf 1.4 gpu 一起使用的正确 keras 版本。什么是正确的?

回答by Ioannis Nasios

Keras - Tensorflow version's compatibility is problem that i have faced many times. I have used in the past (kept in bookmarks), this link, with matches of tensorflowand kerasversions. I believe that keras 2.0.8is compatible with tensorflow 1.4

Keras - Tensorflow 版本的兼容性是我多次遇到的问题。我过去曾使用过(保存在书签中),此链接tensorflowkeras版本匹配。我相信这keras 2.0.8tensorflow 1.4

回答by P-Gn

If you are using keras exclusively with the tensorflow backend, I would recommend to use the keras implementation found in tf.kerasrather than the kerasmodule. That way, you won't scratch your head about possible incompatibilities or bugs (see also that question).

如果您仅将 keras 与 tensorflow 后端一起使用,我建议您使用 keras 中的实现tf.keras而不是keras模块。这样,您就不会因为可能的不兼容或错误而挠头(另请参阅该问题)。

回答by jdehesa

There does not seem to be proper documentation on which Keras version targets which TensorFlow version. The quickest way to solve your problem may be just downgrading Keras one version at a time until you find one that works (or, conversely, upgrading one version at a time from one that you know to work until it breaks). If you find that tedious you can do it as a binary search.

似乎没有关于哪个 Keras 版本针对哪个 TensorFlow 版本的正确文档。解决问题的最快方法可能是一次降级 Keras 一个版本,直到找到一个可用的版本(或者,相反,从一个您知道可以工作的版本一次升级一个版本,直到它崩溃)。如果您觉得这很乏味,您可以将其作为二分搜索来完成。

Looking at the releases page, it seems that version 2.0.8should be compatible with TensorFlow 1.4; it's about a year old already but at least you have an starting point there.

查看发布页面,似乎2.0.8 版本应该与 TensorFlow 1.4 兼容;它已经大约一岁了,但至少你有一个起点。

回答by hobs

I was able to use the conda package managerto install keras and keras-gpu, with a compatible tensorflow and cuda versions to get past your TypeError: softmax()... error message when I was trying to load the original BERT tensorflow checkpointusing the keras-bertpackage:

当我尝试使用keras-bert包加载原始 BERT tensorflow 检查点时,我能够使用conda 包管理器安装 keras 和 keras-gpu,并使用兼容的 tensorflow 和 cuda 版本来解决您的TypeError: softmax()...错误消息:

$ conda create -n bert python=3.6
$ conda activate bert
$ conda install keras==2.0.8
$ conda install keras-gpu==2.0.8
$ pip install keras-pos-embd==0.10.0
$ pip install keras-transformer==0.22.0