私はcifar10 from tensorflowを使用していましたが、モジュールcifar10_input.py
とcifar10.py
には、distorted_inputs
という2つの機能があることに気付きました。ラインで__init__.py
を使用してcifar10_train.py
モジュールをインポート:Pythonは、同じ名前で定義されていて異なるモジュールからインポートされた2つの異なる関数を区別できますか?
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
...
==============================================================================
"""Makes helper libraries available in the cifar10 package."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from tensorflow.models.image.cifar10 import cifar10
from tensorflow.models.image.cifar10 import cifar10_input
それはどのようにdistorted_inputs
のために異なる機能がクラッシュしていないということですか?これは問題ではないですか?以下のようcifar10_train.py
輸入特に
:それは__init__.py
をロードすることを意味する
from tensorflow.models.image.cifar10 import cifar10
。しかし、それを行うと、私を捨てている複数のdistorted_inputs
関数があるようです。
全体cifarライブラリを見つけることができます: https://github.com/tensorflow/tensorflow/tree/r0.11/tensorflow/models/image/cifar10
自分の状況に適用されます知っているが、列車のモジュールはパッケージ全体をインポートする。だから私はパッケージと '__init __。py'を参照しています。各モジュールを 'tensorflow.models.image.cifar10.cifar10'と' tensorflow.models.image.cifar10_input'から別々にインポートしたのであれば、それは明白でした。しかし、それは何が起こっているのではありません。 – Pinocchio
@Pinocchio:「私は知っているが、電車のモジュールはパッケージ全体を輸入する」 - そうではない。また、あなたは「輸入」するつもりは言うまでもなく、「何でも」と言うだけではありません。 – user2357112