Up python 起動,最初の設定 作成: 2021-04-21
更新: 2021-04-21


    作業は,python のインタラクティブ・シェルでの作業となる。


    1. python 起動:
      (venv) $ python >>>

    2. tensorflow を import
      >>> import tensorflow as tf

    3. tf.enable_eager_execution() を実行(註)
      >>> tf.enable_eager_execution()



    註: tf.enable_eager_execution() を実行しておかないと,python コマンドでつぎのエラーが返される場面がいろいろ出てくる (例えば,「データのロード」セクションでの「for x in raw_train_data.take(1): print(x)」):
      Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/pi/venv/lib/python3.7/site-packages/ tensorflow_core/python/data/ops/dataset_ops.py", line 2115, in __iter__ return iter(self._dataset) File "/home/pi/venv/lib/python3.7/site-packages/ tensorflow_core/python/data/ops/dataset_ops.py", line 347, in __iter__ raise RuntimeError("__iter__() is only supported inside of tf.function " RuntimeError: __iter__() is only supported inside of tf.function or when eager execution is enabled. >>>
        また,tf.enable_eager_execution() は,プログラムの始めに実行しなければならない。
    途中でこれを実行すると,つぎのエラーが返される:
      >>>> tf.enable_eager_execution() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/pi/venv/lib/python3.7/site-packages/ tensorflow_core/python/framework/ops.py", line 5584, in enable_eager_execution server_def=None) File "/home/pi/venv/lib/python3.7/site-packages/ tensorflow_core/python/framework/ops.py", line 5643, in enable_eager_execution_internal "tf.enable_eager_execution must be called at program startup.") ValueError: tf.enable_eager_execution must be called at program startup.