13. 在ubuntu16.04(linux)安装配置tensroflow-io

13. 配置tensroflow-io+tensorflow-io-kafka

> 前置环境准备

10. ubuntu16.04配置anaconda+python3+tensorflow+jupyter远程访问

1、安装tensorflow-io

安装到tensorflow环境里,先启动环境

activate source tensorflow

由于conda install不能搜索到tensorflow-io,因此就用pip安装

换成清华镜像源安装tensorflow-io
加上pip install -i https://pypi.tuna.tsinghua.edu.cn/simple

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-io

python-解决pip安装速度慢的问题

注:如果报异常

ERROR: google-auth 1.11.2 has requirement setuptools>=40.3.0, but you'll have setuptools 36.4.0 which is incompatible.
ERROR: tensorboard 2.1.1 has requirement setuptools>=41.0.0, but you'll have setuptools 36.4.0 which is incompatible.
Installing collected packages: gast, wrapt, astor, six, google-pasta, grpcio, numpy, h5py, keras-applications, scipy, opt-einsum, keras-preprocessing, protobuf, idna, certifi, urllib3, chardet, requests, oauthlib, requests-oauthlib, cachetools, pyasn1, rsa, pyasn1-modules, google-auth, google-auth-oauthlib, absl-py, tensorboard, tensorflow-estimator, termcolor, tensorflow, tensorflow-io
  Attempting uninstall: six
    Found existing installation: six 1.10.0
ERROR: Cannot uninstall 'six'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

在这里插入图片描述
解决方法:
更新six和setuptools

$ pip install --ignore-installed six
$ pip install --ignore-installed setuptools

如果显示不能找到对应版本的setuptools就先卸载后安装

$ pip uninstall setuptools
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple  setuptools==41.0.0

Tensorflow2.0安装异常解决

【异常】tensorboard 1.14.0 has requirement setuptools>=41.0.0, but you’ll have setuptools 40.6.3

Tensorflow安装

开启jupyter验证一下

$ jupyter notebook --allow-root > jupyter.log 2>&1 &
[1] 2715

在这里插入图片描述
安装成功

再来使用官方示例测试一下

import tensorflow as tf
import tensorflow_io as tfio

# Read MNIST into Dataset
d_train = tfio.IODataset.from_mnist(
    'http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz',
    'http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz').batch(1)

# By default image data is uint8 so conver to float32.
d_train = d_train.map(lambda x, y: (tf.image.convert_image_dtype(x, tf.float32), y))

model = tf.keras.models.Sequential([
  tf.keras.layers.Flatten(input_shape=(28, 28)),
  tf.keras.layers.Dense(512, activation=tf.nn.relu),
  tf.keras.layers.Dropout(0.2),
  tf.keras.layers.Dense(10, activation=tf.nn.softmax)
])
model.compile(optimizer='adam',
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])

model.fit(d_train, epochs=5, steps_per_epoch=10000)

在这里插入图片描述
拓展知识:
python 如何找到import的包

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

辰阳星宇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值