如何在火炬中训练caffe模型

时间:2017-09-30 04:01:05

标签: deep-learning caffe torch

我使用torch-caffe-binding将caffe模型加载到火炬,示例显示

require 'caffe'
net = caffe.Net('deploy.prototxt', 'bvlc_alexnet.caffemodel', 'test') 
input = torch.FloatTensor(10,3,227,227)
output = net:forward(input)
gradOutput = torch.FloatTensor(10,1000,1,1)
gradInput = net:backward(input, gradOutput)

但是当我使用向后训练网时,无论训练多少次,输入相同数据时输出都不会改变。所以如何训练caffe模型,提前谢谢。
添加
对不起,我没有说清楚。我的代码是这样的:

caffenet = caffe.Net('test.prototxt','test2.caffemodel','train')
caffe_output = caffenet:forward(input)
local predParts=netPred:forward(caffe_output)
netPred:backward(caffe_output, gradPred)
caffenet:backward(input,g) 

netPred是一个火炬网,caffenet是一个删除最后一个丢失图层的网。但是我设置了第二个最后一层loss_weight=1,控制台显示了所有这样的图层{{} 1}},但是当我使用ip1 needs backward computation.时,我检查输出从未改变。甚至我添加了丢失层它也没有用。

0 个答案:

没有答案