질문CAFFE 테스트 순 내 그물 라운드의 손실이 훈련 일부 후 0과 1 사이의 값으로, 내가 레이블로 이미지를 사용하여 오전 CNN을 만들려고
레이블로 약 23 이제 결과를보고 싶습니다.() 나는 approximatly 5.92 및 result.min를 반환) (0과 1 그러나 현실 result.max에서을로 결과 값을 기대하고 이제 수익을
import caffe
import numpy as np
from PIL import Image
net = caffe.Net('D:/caffe/net.prototxt',
'D:/caffe/net_iter_35000.caffemodel',
caffe.TEST)
# load input and configure preprocessing
transformer = caffe.io.Transformer({'data': net.blobs['data'].data.shape})
transformer.set_mean('data', np.load('train_mean.npy').mean(1).mean(1))
transformer.set_transpose('data', (2,0,1))
transformer.set_channel_swap('data', (2,1,0))
transformer.set_raw_scale('data', 255.0)
#note we can change the batch size on-the-fly
#since we classify only one image, we change batch size from 10 to 1
net.blobs['data'].reshape(1,3,360,360)
#load the image in the data layer
im = caffe.io.load_image('train/img0.png')
net.blobs['data'].data[...] = transformer.preprocess('data', im)
#compute
out = net.forward()
result = out['conv7'][0][0]
:이 목적을 위해 나는이 파이썬 스크립트를 사용하고 있습니다 -4315.5.
파이썬 스크립트에 실수가 있습니까? 아니면 23의 손실에 대해이 값이 정상입니까?
추가 정보를 정기적으로
내 train_test.prototxt :
layer {
name: "mynet"
type: "Data"
top: "data0"
top: "label0"
include {
phase: TRAIN
}
transform_param {
mean_file: "train_mean.binaryproto"
scale: 0.00390625
}
data_param {
source: "train_lmdb"
batch_size: 32
backend: LMDB
}
}
layer {
name: "mynetlabel"
type: "Data"
top: "data1"
top: "label1"
include {
phase: TRAIN
}
transform_param {
scale: 0.00390625
}
data_param {
source: "train_label_lmdb_2"
batch_size: 32
backend: LMDB
}
}
layer {
name: "mnist"
type: "Data"
top: "data0"
top: "label0"
include {
phase: TEST
}
transform_param {
mean_file: "train_mean.binaryproto"
scale: 0.00390625
}
data_param {
source: "val_lmdb"
batch_size: 16
backend: LMDB
}
}
layer {
name: "mnistlabel"
type: "Data"
top: "data1"
top: "label1"
include {
phase: TEST
}
transform_param {
scale: 0.00390625
}
data_param {
source: "val_label_lmdb_2"
batch_size: 16
backend: LMDB
}
}
.
.
.
layer {
name: "conv7"
type: "Convolution"
bottom: "conv6"
top: "conv7"
param {
lr_mult: 5.0
decay_mult: 1.0
}
param {
lr_mult: 10.0
decay_mult: 0.0
}
convolution_param {
num_output: 1
pad: 0
kernel_size: 1
weight_filler {
type: "gaussian"
std: 0.00999999977648
}
bias_filler {
type: "constant"
}
}
}
layer {
name: "accuracy"
type: "Accuracy"
bottom: "conv7"
bottom: "data1"
top: "accuracy"
include {
phase: TEST
}
}
layer {
name: "loss"
type: "SigmoidCrossEntropyLoss"
bottom: "conv7"
bottom: "data1"
top: "loss"
}
내 net.prototxt :
layer {
name: "data"
type: "Input"
top: "data"
input_param { shape: { dim: 50 dim: 3 dim: 360 dim: 360 } }
transform_param {
scale: 0.00390625
}
}
.
.
.
layer {
name: "conv7"
type: "Convolution"
bottom: "conv6"
top: "conv7"
param {
lr_mult: 5.0
decay_mult: 1.0
}
param {
lr_mult: 10.0
decay_mult: 0.0
}
convolution_param {
num_output: 1
pad: 0
kernel_size: 1
weight_filler {
type: "gaussian"
std: 0.00999999977648
}
bias_filler {
type: "constant"
}
}
}
우선 Shai 당신은 대단합니다. 추신 : 나는 이미지를 라벨로 사용하고 있으며이 이미지의 여러 위치는 0과 1 사이의 값일 수 있습니다 (바이너리 0과 1은 아님). 그래서 나는 이것이 당신이 말하는 것을 정확하게 추측하고있는 것이 아닙니다. SigmoidWithCrossEntropy 대신 SoftmaxWithLoss를 사용 하시겠습니까? 아니면 당신의 대답을 정확하게 이해하지 못하고 있습니까? – SimpleNotGood
@SimpleNotGood''정확도''에 관해서 :이 레이어를 사용하여 단일 출력 예측의 정확도를 측정 할 수 없습니다. Caffe의 "정확도"레이어는 분류 작업의 정확도 만 측정하도록 설계되었습니다. ** 연속 **, 단일 희미한, 예측의 정확도를 측정하려면 다른 방법을 사용해야합니다. – Shai
@SimpleNotGood 예측값이 범위 [0,1]의 연속 값이면 'Sigmoid'대신''Softmax ''를 사용할 필요가없는 것처럼 보입니다. – Shai