回帰問題のためにNNを訓練しました。私のデータ型は、.jpg
の画像(3X256X256)と浮動小数点配列(3つのラベル)で作られたHDF5_DATA
です。データセットのスクリプトを作成するには:Caffe損失のフロートマルチラベル回帰
import h5py, os
import caffe
import numpy as np
SIZE = 256 # images size
with open('/home/path/trainingTintText.txt', 'r') as T :
lines = T.readlines()
X = np.zeros((len(lines), 3, SIZE, SIZE), dtype='f4')
labels = np.zeros((len(lines),3), dtype='f4')
for i,l in enumerate(lines):
sp = l.split(' ')
img = caffe.io.load_image(sp[0])
img = caffe.io.resize(img, (SIZE, SIZE, 3))
transposed_img = img.transpose((2,0,1))[::-1,:,:] # RGB->BGR
X[i] = transposed_img*255
print X[i]
labels[i,0] = float(sp[1])
labels[i,1] = float(sp[2])
labels[i,2] = float(sp[3])
with h5py.File('/home/path/train.h5','w') as H:
H.create_dataset('data', data=X)
H.create_dataset('label', data=labels)
with open('/home/path/train_h5_list.txt','w') as L:
L.write('/home/path/train.h5')
これは(fullishない)アーキテクチャです:
I1117 08:15:57.707001 2767 solver.cpp:337] Iteration 0, Testing net (#0)
I1117 08:15:57.707033 2767 net.cpp:684] Ignoring source layer fkp
I1117 08:15:59.111842 2767 solver.cpp:404] Test net output #0: loss = 256.672 (* 1 = 256.672 loss)
I1117 08:15:59.275205 2767 solver.cpp:228] Iteration 0, loss = 278.909
I1117 08:15:59.275255 2767 solver.cpp:244] Train net output #0: loss = 278.909 (* 1 = 278.909 loss)
I1117 08:15:59.275276 2767 sgd_solver.cpp:106] Iteration 0, lr = 0.01
I1117 08:16:57.115145 2767 solver.cpp:337] Iteration 100, Testing net (#0)
I1117 08:16:57.115486 2767 net.cpp:684] Ignoring source layer fkp
I1117 08:16:58.884704 2767 solver.cpp:404] Test net output #0: loss = 238.257 (* 1 = 238.257 loss)
I1117 08:16:59.026926 2767 solver.cpp:228] Iteration 100, loss = 191.836
I1117 08:16:59.026971 2767 solver.cpp:244] Train net output #0: loss = 191.836 (* 1 = 191.836 loss)
I1117 08:16:59.026993 2767 sgd_solver.cpp:106] Iteration 100, lr = 0.01
I1117 08:17:56.890614 2767 solver.cpp:337] Iteration 200, Testing net (#0)
I1117 08:17:56.890880 2767 net.cpp:684] Ignoring source layer fkp
I1117 08:17:58.665057 2767 solver.cpp:404] Test net output #0: loss = 208.236 (* 1 = 208.236 loss)
I1117 08:17:58.809150 2767 solver.cpp:228] Iteration 200, loss = 136.422
I1117 08:17:58.809248 2767 solver.cpp:244] Train net output #0: loss = 136.422 (* 1 = 136.422 loss)
私は分ける:私はNNを訓練するとき
name: "NN"
layers {
name: "NNd"
top: "data"
top: "label"
type: HDF5_DATA
hdf5_data_param {
source: "/home/path/train_h5_list.txt"
batch_size: 64
}
include: { phase: TRAIN }
}
layers {
name: "data"
type: HDF5_DATA
top: "data"
top: "label"
hdf5_data_param {
source: "/home/path/train_h5_list.txt"
batch_size: 100
}
include: { phase: TEST }
}
layers {
name: "conv1"
type: CONVOLUTION
bottom: "data"
top: "conv1"
convolution_param {
num_output: 32
kernel_size: 11
stride: 2
bias_filler {
type: "constant"
value: 0.1
}
}
}
layers {
name: "ip2"
type: INNER_PRODUCT
bottom: "ip1"
top: "ip2"
inner_product_param {
num_output: 3
bias_filler {
type: "constant"
value: 0.1
}
}
}
layers {
name: "relu22"
type: RELU
bottom: "ip2"
top: "ip2"
}
layers {
name: "loss"
type: EUCLIDEAN_LOSS
bottom: "ip2"
bottom: "label"
top: "loss"
}
は、私は非常に高い損失値を得ました画像とラベル配列255
で私は非常に低い損失の結果を得た(きれいに0
に)。これらの損失結果の理由は何ですか?私は何か間違っているのですか?ありがとう
クロス投稿:http://stackoverflow.com/q/40280068/781723、http://cs.stackexchange.com/q/65185/755。複数のサイトに同じ質問を投稿しないでください(http://meta.stackexchange.com/q/64068)。誰も時間を無駄にすることなく、それぞれのコミュニティは答えに正直な打撃を与えるべきです。 –
はそれを得ました。ありがとう。あなたは私の質問の答えがありますか? –
@ D.W。私は自分の質問を編集しました。お返事ありがとう –