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

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

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

gnuplot(ニュープロット)は、2次元や3次元のグラフ作成ができるソフトウェアです。さまざまな数式やデータ集計などのグラフを描写することが可能で、特に2次元グラフを描画する機能は強力です。

Caffe

Caffeは、深層学習に用いられるオープンソースフレームワークの一つです。C++で実装されており、C++/Python/MATLABで用いることができます。画像認識に特化しており、動作も早い点が特徴。GUPにも対応しています。

Linux

Linuxは、Unixをベースにして開発されたオペレーティングシステムです。日本では「リナックス」と呼ばれています。 主にWebサーバやDNSサーバ、イントラネットなどのサーバ用OSとして利用されています。 上位500のスーパーコンピュータの90%以上はLinuxを使用しています。 携帯端末用のプラットフォームAndroidは、Linuxカーネル上に構築されています。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

Q&A

解決済

1回答

1502閲覧

Ubuntuでテキストファイルをコマンドで更新する方法

kaffe-marsh

総合スコア13

gnuplot

gnuplot(ニュープロット)は、2次元や3次元のグラフ作成ができるソフトウェアです。さまざまな数式やデータ集計などのグラフを描写することが可能で、特に2次元グラフを描画する機能は強力です。

Caffe

Caffeは、深層学習に用いられるオープンソースフレームワークの一つです。C++で実装されており、C++/Python/MATLABで用いることができます。画像認識に特化しており、動作も早い点が特徴。GUPにも対応しています。

Linux

Linuxは、Unixをベースにして開発されたオペレーティングシステムです。日本では「リナックス」と呼ばれています。 主にWebサーバやDNSサーバ、イントラネットなどのサーバ用OSとして利用されています。 上位500のスーパーコンピュータの90%以上はLinuxを使用しています。 携帯端末用のプラットフォームAndroidは、Linuxカーネル上に構築されています。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

0グッド

0クリップ

投稿2018/11/11 07:14

Ubuntu上でCaffeを使い、機械学習を実行しています。

学習が終わった際にLossとAccuracyのグラフを描画しています。
この時にCaffeに元から入っていた"plot_log.gnuplot.example"というファイルを元にグラフを作っています。

# These snippets serve only as basic examples. # Customization is a must. # You can copy, paste, edit them in whatever way you want. # Be warned that the fields in the training log may change in the future. # You had better check the data files before designing your own plots. # Please generate the necessary data files with # /path/to/caffe/tools/extra/parse_log.sh before plotting. # Example usage: # ./parse_log.sh mnist.log # Now you have mnist.log.train and mnist.log.test. # gnuplot mnist.gnuplot # The fields present in the data files that are usually proper to plot along # the y axis are test accuracy, test loss, training loss, and learning rate. # Those should plot along the x axis are training iterations and seconds. # Possible combinations: # 1. Test accuracy (test score 0) vs. training iterations / time; # 2. Test loss (test score 1) time; # 3. Training loss vs. training iterations / time; # 4. Learning rate vs. training iterations / time; # A rarer one: Training time vs. iterations. # What is the difference between plotting against iterations and time? # If the overhead in one iteration is too high, one algorithm might appear # to be faster in terms of progress per iteration and slower when measured # against time. And the reverse case is not entirely impossible. Thus, some # papers chose to only publish the more favorable type. It is your freedom # to decide what to plot. reset set terminal png set output "your_chart_name.png" set style data lines set key right ###### Fields in the data file your_log_name.log.train are ###### Iters Seconds TrainingLoss LearningRate # Training loss vs. training iterations #set title "Training loss vs. training iterations" #set xlabel "Training iterations" #set ylabel "Training loss" #plot "mnist.log.train" using 1:3 title "mnist" # Training loss vs. training time # plot "mnist.log.train" using 2:3 title "mnist" # Learning rate vs. training iterations; # plot "mnist.log.train" using 1:4 title "mnist" # Learning rate vs. training time; # plot "mnist.log.train" using 2:4 title "mnist" ###### Fields in the data file your_log_name.log.test are ###### Iters Seconds TestAccuracy TestLoss # Test loss vs. training iterations # plot "mnist.log.test" using 1:4 title "mnist" # Test accuracy vs. training iterations # plot "mnist.log.test" using 1:3 title "mnist" # Test loss vs. training time # plot "mnist.log.test" using 2:4 title "mnist" # Test accuracy vs. training time plot "mnist.log.test" using 2:3 title "mnist"

この時、.trainと.testというファイルから数値を取得してグラフを作っているのだと思うのですが、フォルダ内にあるこれらの拡張子を持つファイル名を順番に取得して、テキストファイルを更新していくにはどのようなコマンドで記述すればいいのでしょうか。

例えばフォルダ内に
aaa.train
aaa.test
bbb.train
bbb.test
ccc.train
ccc.test
という風にファイルがある時に、テキストファイル内の

plot "mnist.test" using 2:3 title "mnist"

"mnist"の部分を"aaa"に更新してgnuplotでグラフを書き、
その後に"aaa"を"bbb"、"bbb"を"ccc"に変えていきフォルダ内の全てのグラフを描画したいと思っています。

知識がないため、上手く説明ができていないかもしれませんが
ご教示よろしくお願いいたします。

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

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

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

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

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

guest

回答1

0

ベストアンサー

テキストファイルとコマンド実行の関係が分かりませんでしたが、

shell

1for f in `ls *.{train,test} | sed -r "s/..+$//" | uniq` 2do 3 echo plot \"$f.test\" using 2:3 title \"$f\" 4done

このような処理実行が参考になりませんか?

投稿2018/11/11 12:54

matsuand

総合スコア186

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.49%

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

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

質問する

関連した質問