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

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

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

強化学習とは、ある環境下のエージェントが現状を推測し行動を決定することで報酬を獲得するという見解から、その報酬を最大限に得る方策を学ぶ機械学習のことを指します。問題解決時に得る報酬が選択結果によって変化することで、より良い行動を選択しようと学習する点が特徴です。

Anaconda

Anacondaは、Python本体とPythonで利用されるライブラリを一括でインストールできるパッケージです。環境構築が容易になるため、Python開発者間ではよく利用されており、商用目的としても利用できます。

Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

Python

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

Q&A

解決済

1回答

2078閲覧

ML-Agentsで機械学習始まらない(Unity)

ryo-maker

総合スコア1

強化学習

強化学習とは、ある環境下のエージェントが現状を推測し行動を決定することで報酬を獲得するという見解から、その報酬を最大限に得る方策を学ぶ機械学習のことを指します。問題解決時に得る報酬が選択結果によって変化することで、より良い行動を選択しようと学習する点が特徴です。

Anaconda

Anacondaは、Python本体とPythonで利用されるライブラリを一括でインストールできるパッケージです。環境構築が容易になるため、Python開発者間ではよく利用されており、商用目的としても利用できます。

Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

Python

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

0グッド

0クリップ

投稿2021/11/07 03:18

編集2021/11/10 12:31

前提・実現したいこと

UnityのML-Agentsで機械学習を実行したいです。
https://qiita.com/2019Shun/items/d811bbd470fc9cddcc3d
上記の記事の通りにコマンドプロンプトで実行した際に以下のようなメッセージが表示されました。

発生している問題・エラーメッセージ

問題としては、10分程かかる機械学習がすぐに終わってしまい、結果が取得できませんでした。

2021-11-07 11:58:23.919168: E tensorflow/core/lib/monitoring/collection_registry.cc:77] Cannot register 2 metrics with the same name: /tensorflow/api/keras/optimizers 2021-11-07 11:58:23 INFO [trainer_controller.py:108] Saved Model Traceback (most recent call last): File "C:\Users\Handa\anaconda3\envs\ml-agents\Scripts\mlagents-learn-script.py", line 33, in <module> sys.exit(load_entry_point('mlagents', 'console_scripts', 'mlagents-learn')()) File "d:\unity_projects\ml-agents-release_3\ml-agents\mlagents\trainers\learn.py", line 322, in main run_cli(parse_command_line()) File "d:\unity_projects\ml-agents-release_3\ml-agents\mlagents\trainers\learn.py", line 318, in run_cli run_training(run_seed, options) File "d:\unity_projects\ml-agents-release_3\ml-agents\mlagents\trainers\learn.py", line 163, in run_training tc.start_learning(env_manager) File "d:\unity_projects\ml-agents-release_3\ml-agents-envs\mlagents_envs\timers.py", line 305, in wrapped return func(*args, **kwargs) File "d:\unity_projects\ml-agents-release_3\ml-agents\mlagents\trainers\trainer_controller.py", line 218, in start_learning self._create_trainers_and_managers(env_manager, new_behavior_ids) File "d:\unity_projects\ml-agents-release_3\ml-agents\mlagents\trainers\trainer_controller.py", line 204, in _create_trainers_and_managers self._create_trainer_and_manager(env_manager, behavior_id) File "d:\unity_projects\ml-agents-release_3\ml-agents\mlagents\trainers\trainer_controller.py", line 180, in _create_trainer_and_manager trainer.add_policy(parsed_behavior_id, policy) File "d:\unity_projects\ml-agents-release_3\ml-agents\mlagents\trainers\ppo\trainer.py", line 232, in add_policy self.optimizer = PPOOptimizer(self.policy, self.trainer_settings) File "d:\unity_projects\ml-agents-release_3\ml-agents\mlagents\trainers\ppo\optimizer.py", line 21, in __init__ policy.create_tf_graph() File "d:\unity_projects\ml-agents-release_3\ml-agents\mlagents\trainers\policy\nn_policy.py", line 91, in create_tf_graph self.vis_encode_type, File "d:\unity_projects\ml-agents-release_3\ml-agents\mlagents\trainers\policy\nn_policy.py", line 169, in _create_encoder vis_encode_type, File "d:\unity_projects\ml-agents-release_3\ml-agents\mlagents\trainers\models.py", line 581, in create_observation_streams reuse=False, File "d:\unity_projects\ml-agents-release_3\ml-agents\mlagents\trainers\models.py", line 267, in create_vector_observation_encoder hidden = tf.layers.dense( File "C:\Users\Handa\anaconda3\envs\ml-agents\lib\site-packages\tensorflow\python\util\lazy_loader.py", line 62, in __getattr__ module = self._load() File "C:\Users\Handa\anaconda3\envs\ml-agents\lib\site-packages\tensorflow\python\util\lazy_loader.py", line 45, in _load module = importlib.import_module(self.__name__) File "C:\Users\Handa\anaconda3\envs\ml-agents\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "C:\Users\Handa\anaconda3\envs\ml-agents\lib\site-packages\keras\__init__.py", line 25, in <module> from keras import models File "C:\Users\Handa\anaconda3\envs\ml-agents\lib\site-packages\keras\models.py", line 20, in <module> from keras import metrics as metrics_module File "C:\Users\Handa\anaconda3\envs\ml-agents\lib\site-packages\keras\metrics.py", line 26, in <module> from keras import activations File "C:\Users\Handa\anaconda3\envs\ml-agents\lib\site-packages\keras\activations.py", line 20, in <module> from keras.layers import advanced_activations File "C:\Users\Handa\anaconda3\envs\ml-agents\lib\site-packages\keras\layers\__init__.py", line 23, in <module> from keras.engine.input_layer import Input File "C:\Users\Handa\anaconda3\envs\ml-agents\lib\site-packages\keras\engine\input_layer.py", line 21, in <module> from keras.engine import base_layer File "C:\Users\Handa\anaconda3\envs\ml-agents\lib\site-packages\keras\engine\base_layer.py", line 43, in <module> from keras.mixed_precision import loss_scale_optimizer File "C:\Users\Handa\anaconda3\envs\ml-agents\lib\site-packages\keras\mixed_precision\loss_scale_optimizer.py", line 18, in <module> from keras import optimizers File "C:\Users\Handa\anaconda3\envs\ml-agents\lib\site-packages\keras\optimizers.py", line 26, in <module> from keras.optimizer_v2 import adadelta as adadelta_v2 File "C:\Users\Handa\anaconda3\envs\ml-agents\lib\site-packages\keras\optimizer_v2\adadelta.py", line 22, in <module> from keras.optimizer_v2 import optimizer_v2 File "C:\Users\Handa\anaconda3\envs\ml-agents\lib\site-packages\keras\optimizer_v2\optimizer_v2.py", line 37, in <module> "/tensorflow/api/keras/optimizers", "keras optimizer usage", "method") File "C:\Users\Handa\anaconda3\envs\ml-agents\lib\site-packages\tensorflow\python\eager\monitoring.py", line 361, in __init__ len(labels), name, description, *labels) File "C:\Users\Handa\anaconda3\envs\ml-agents\lib\site-packages\tensorflow\python\eager\monitoring.py", line 135, in __init__ self._metric = self._metric_methods[self._label_length].create(*args) tensorflow.python.framework.errors_impl.AlreadyExistsError: Another metric with the same name already exists.

該当のソースコード

mlagents-learn config/ppo/3DBall.yaml --run-id=first3DBallRun

試したこと

https://note.com/npaka/n/n167b2d03a347?magazine_key=m50f437a3f5e1#gqC2O
https://zenn.dev/kathmandu/articles/91e401bd070971

補足情報(FW/ツールのバージョンなど)

https://teratail.com/questions/265678
https://teratail.com/questions/223130?link=qa_related_pc
とほぼ同じエラーですがなかなか解決できません。。。

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

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

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

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

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

jbpb0

2021/11/07 07:45

> Another metric with the same name already exists. https://github.com/tensorflow/tensorflow/issues/51592 によると、TensorFlow 2.6とKeras 2.7の組み合わせだと起きるようで、Kerasを2.6に入れ直したら直ったと書かれてます 上記が書かれた後にTensorFlow 2.7が出てるので、Kerasは2.7のままでTensorFlowを2.7にアップデートしても直るかもしれません
jbpb0

2021/11/07 07:47

質問のタグに「Unity」を追加した方がいいと思います 「Unity」を使ってて、同じエラーに悩んでる人が他にもいるかもしれませんので
jbpb0

2021/11/07 08:44 編集

質問のエラーとは直接は関係無いかもしれませんが、質問者さんが参考にしてる https://qiita.com/2019Shun/items/d811bbd470fc9cddcc3d に書かれてる手順通りにやると、1年半くらい前に出た古いML-Agentsが入ると思います https://qiita.com/2019Shun/items/d811bbd470fc9cddcc3d では「git clone --branch release_3 https://github.com/Unity-Technologies/ml-agents.git」と、1年半くらい前に出た古い「release_3」を入れるように書かれてますが、 https://www.suzu6.net/posts/270-isntall-unity-ml-agents/ では「git clone --branch release_12 https://github.com/Unity-Technologies/ml-agents.git」と、もっと新しい(それでも1年くらい前)「release_12」を入れるように書かれてますし、 https://github.com/Unity-Technologies/ml-agents/releases を見ると、さらに新しい「Release 18」が出てます この質問のエラーは、最初のコメントに書いたようにTensorFlowとKerasのバージョンの組み合わせで起きてるようなので、ML-Agentsの新しいのを入れても解決しないかもしれませんが、古いML-Agentsと、新しい(TensorFlow等の)Pythonモジュールの組み合わせだと、また別の不具合が発生するかもしれないので、あまり古いML-Agentsのバージョンは入れない方がいいかもしれません 【追記】 「Release 18」のインストール手順が解説されてるWebページもありました https://note.com/npaka/n/ndd679aa343ea https://zenn.dev/karaage0703/articles/4a1c9b1c5185d4
ryo-maker

2021/11/10 14:25 編集

https://github.com/tensorflow/tensorflow/issues/51592 上記の通りKerasバージョンダウンしたらできました!! ML-Agents Release 3でもできました!! 親切丁寧にありがとうございました!! 追記 https://amzn.to/3qqCiRy の参考書(2020/08出版)でもML-Agents Release 3でのやり方が書いてあったのですが、できるだけ最新のReleaseでやっていこうと思います!!
guest

回答1

0

ベストアンサー

Another metric with the same name already exists.

AlreadyExistsError: Another metric with the same name already exists #51592
によると、TensorFlow 2.6とKeras 2.7の組み合わせだと起きるようで、Kerasを2.6に入れ直したら直ったと書かれてます

上記が書かれた後にTensorFlow 2.7が出てるので、Kerasは2.7のままでTensorFlowを2.7にアップデートしても直るかもしれません

投稿2021/11/11 02:48

jbpb0

総合スコア7651

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問