import keras: TypeError: __new__() got an unexpected keyword argument 'file'

Keras 与 Tensorflow 版本不兼容导致。

Keras 版本:2.1.5

$ pip show keras
Name: Keras
Version: 2.1.5
Summary: Deep Learning for humans
Home-page: https://github.com/keras-team/keras
Author: Francois Chollet
Author-email: francois.chollet@gmail.com
License: MIT
Location: /anaconda3/lib/python3.6/site-packages
Requires: numpy, pyyaml, scipy, six

目前,pip 安装的最新的 Tensorflow 版本是 1.7.0,不兼容。

解决办法:

  • conda 使用 Tsinghua 镜像源:https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  • conda 能安装较低版本的 Tensorflow

Tensorflow 版本:1.1.0

$ pip show tensorflow
Name: tensorflow
Version: 1.1.0
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: opensource@google.com
License: Apache 2.0
Location: /anaconda3/lib/python3.6/site-packages
Requires: wheel, six, numpy, protobuf, werkzeug

输出:

Using TensorFlow backend. # 使用 Tensorflow 作为后台搭建网络
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容