質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

1回答

4887閲覧

ModuleNotFoundError: No module named 'tensorflow.contrib'を解決したい

867Lion

総合スコア0

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2020/12/21 14:03

pyton

1import numpy as np 2import tensorflow as tf 3import os 4if tf.io.gfile.exists('./fenwicks'): 5 tf.io.gfile.rmtree('./fenwicks') 6!git clone -q https://github.com/fenwickslab/fenwicks.git 7import fenwicks as fw 8fw.colab_utils.setup_gcs()

上記のコードをgooglegolabに書くと下記のエラーがでました。これはどのようにして改善すべきでしょうか
cifar10を使いgooglecolabのtpuで動かすということをしています。

python

1--------------------------------------------------------------------------- 2ModuleNotFoundError Traceback (most recent call last) 3<ipython-input-13-e7475465a85a> in <module>() 4 5 tf.io.gfile.rmtree('./fenwicks') 5 6 get_ipython().system('git clone -q https://github.com/fenwickslab/fenwicks.git ') 6----> 7 import fenwicks as fw 7 8 fw.colab_utils.setup_gcs() 8 91 frames 10/content/fenwicks/data.py in <module>() 11 9 from . import io 12 10 13---> 11 from tensorflow.contrib.tpu.python.tpu import datasets as tpu_datasets 14 12 15 13 16 17ModuleNotFoundError: No module named 'tensorflow.contrib' 18 19--------------------------------------------------------------------------- 20NOTE: If your import is failing due to a missing package, you can 21manually install dependencies using either !pip or !apt. 22 23To view examples of installing some common dependencies, click the 24"Open Examples" button below. 25---------------------------------------------------------------------------

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

質問者さんがお使いのtensorflowのバージョンが不明ですが、tensorflow 1.15 を使用すればModuleNotFoundError: No module named 'tensorflow.contrib'のエラーは解消するはずです。


【追記】実行結果

WARNING:tensorflow: The TensorFlow contrib module will not be included in TensorFlow 2.0. For more information, please see: * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md * https://github.com/tensorflow/addons * https://github.com/tensorflow/io (for I/O related ops) If you depend on functionality not listed there, please file an issue. WARNING:tensorflow:From /content/fenwicks/train.py:159: The name tf.losses.Reduction is deprecated. Please use tf.compat.v1.losses.Reduction instead. --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-2-e7475465a85a> in <module>() 5 tf.io.gfile.rmtree('./fenwicks') 6 get_ipython().system('git clone -q https://github.com/fenwickslab/fenwicks.git ') ----> 7 import fenwicks as fw 8 fw.colab_utils.setup_gcs() 1 frames /content/fenwicks/__init__.py in <module>() 9 from .utils import colab as colab_utils 10 ---> 11 from .vision.models import keras_models 12 from .vision import transform 13 from .vision import image /content/fenwicks/vision/models/__init__.py in <module>() 3 from tensorflow.python.keras import engine as keras_engine 4 ----> 5 keras_applications.set_keras_submodules(backend=tf.keras.backend, layers=tf.keras.layers, models=tf.keras.models, 6 utils=tf.keras.utils, engine=keras_engine) AttributeError: module 'keras_applications' has no attribute 'set_keras_submodules'

投稿2020/12/21 14:35

編集2020/12/22 00:56
meg_

総合スコア10594

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

867Lion

2020/12/21 14:49

ターミナルで確認してみます。
867Lion

2020/12/21 15:30

colabの中に!pip install tensorflow==1.15.0でやってみたところ同じエラーがでました。これはどうしたらいいでしょうか。
867Lion

2020/12/21 15:35

ターミナルでpip install tensorflow==1.15.0をやってみて再度ランタイムでセルを実行しても同じエラーがでました。解決策をご教示いただきたいです。
867Lion

2020/12/21 15:35

macでやっています
meg_

2020/12/22 00:53 編集

googlegolab(ランタイムはCPU、GPU、TPU)で検証したところ「ModuleNotFoundError: No module named 'tensorflow.contrib'」のエラーは出ませんでした。※但しWarningと他のエラーは出ます。 別のエラーの解消方法については別途質問を立てていただきたいです。※fenwicksについては知らないため
867Lion

2020/12/22 05:16

何かをインストールしていないかとかですか。colabに打ったコードをこちらに貼っていただけますか
meg_

2020/12/22 09:12

私が実行したのはtensorflow 1.15のインストールと質問のコードのみです。
867Lion

2020/12/22 15:50

ありがとうございます。違う問題が出たのでまた質問を投稿しようと思います
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問