2016-12-10 17 views

答えて

14

あなたは、データを抽出するためにTensorBoardのPythonのクラスまたはスクリプトを使用することができます。

How can I export data from TensorBoard?

あなたが他の場所(例えばiPythonノートブック)を可視化するためにデータをエクスポートしたい場合は、それも可能です。 TensorBoardがデータをロードするために使用する基本クラス(単一実行からデータをロードする場合はpython/summary/event_accumulator.py)または複数実行からデータをロードして構成する場合はpython/summary/event_multiplexer.pyに直接依存することができます。これらのクラスは、イベントファイルのグループをロードし、TensorFlowクラッシュによって "孤立した"データを破棄し、タグでデータを整理します。

別のオプションとして、TensorBoardと同じようにlogdirをロードするスクリプトがありますが、サーバを起動する代わりにすべてのデータをjsonとしてディスクに書き出します。このスクリプトはテスト用に "偽のTensorBoardバックエンド"を作成するように設定されているため、少し荒いです。

In [1]: from tensorflow.python.summary import event_accumulator 

In [2]: ea = event_accumulator.EventAccumulator('events.out.tfevents.x.ip-x-x-x-x', 
    ...: size_guidance={ # see below regarding this argument 
    ...:  event_accumulator.COMPRESSED_HISTOGRAMS: 500, 
    ...:  event_accumulator.IMAGES: 4, 
    ...:  event_accumulator.AUDIO: 4, 
    ...:  event_accumulator.SCALARS: 0, 
    ...:  event_accumulator.HISTOGRAMS: 1, 
    ...: }) 

In [3]: ea.Reload() # loads events from file 
Out[3]: <tensorflow.python.summary.event_accumulator.EventAccumulator at 0x7fdbe5ff59e8> 

In [4]: ea.Tags() 
Out[4]: 
{'audio': [], 
'compressedHistograms': [], 
'graph': True, 
'histograms': [], 
'images': [], 
'run_metadata': [], 
'scalars': ['Loss', 'Epsilon', 'Learning_rate']} 

In [5]: ea.Scalars('Loss') 
Out[5]: 
[ScalarEvent(wall_time=1481232633.080754, step=1, value=1.6365480422973633), 
ScalarEvent(wall_time=1481232633.2001867, step=2, value=1.2162202596664429), 
ScalarEvent(wall_time=1481232633.3877788, step=3, value=1.4660096168518066), 
ScalarEvent(wall_time=1481232633.5749283, step=4, value=1.2405034303665161), 
ScalarEvent(wall_time=1481232633.7419815, step=5, value=0.897326648235321), 
...] 

size_guidanceEventAccumulatorを使用して

size_guidance: Information on how much data the EventAccumulator should 
    store in memory. The DEFAULT_SIZE_GUIDANCE tries not to store too much 
    so as to avoid OOMing the client. The size_guidance should be a map 
    from a `tagType` string to an integer representing the number of 
    items to keep per tag for items of that `tagType`. If the size is 0, 
    all events are stored. 
+0

で簡単にCSVファイルにスカラーのリストをエクスポートすることができますこれらのスクリプトで正確に何を使用するかの実例を提供してください。 – mikal94305

+4

Tensorflowのバージョン1.1.0以降、event_accumulatorはtensorflow/tensorflow/tensorboard/backend/event_processingに移動されました。バージョン1.1.0でコードを動作させるには、import文を 'tensorflow.tensorboard.backend.event_processing import event_accumulator' [詳細はこちら](https://github.com/tensorflow/tensorflow/issues/9532)にする必要があります。 – Chepe

+2

1.3の時点で、TensorFlowレポから専用のTensorBoardレポに移動しました。新しい家庭:https://github.com/tensorflow/tensorboard。 スタンドアロンパッケージとしてピップインストールすることができます。import文は次のようになりました: 'from tensorboard.backend.event_processing import event_accumulator' –

2

user1501961の答えを完了するには、そしてちょうどパンダpd.DataFrame(ea.Scalars('Loss)).to_csv('Loss.csv')

関連する問題