Modify the input images before training in MATLAB

13 views
Skip to first unread message

Christos Nikolaou

unread,
Sep 18, 2016, 5:35:05 AM9/18/16
to Caffe Users
I am using the MATLAB interface to create a training routine where I would like to load an image batch to the network, then modify the images and then using them for training. Is there a way to do that?

In a simple scenario, I am using the lenet_train_test.prototxt file to define a network. Then I am using the forward_prefilled() to load the first batch and then train with it. Then I would like to read the data from the data layer, modify them, load them again and train again. But, I cannot make that work, because calling forward_prefilled() loads the new batch.

net_file = '~/caffe/examples/mnist/lenet_train_test.prototxt';
net = caffe.Net(net_file,'train');

for ii = 1:niter
   
    net.forward_prefilled()
    
   if (ii >= adversarial_iteration_start)
        current_input_data = net.blobs('data').get_data()
        
        modified_input_data = current_input_data; % just for testing, no modification is written
        net.blobs('data').set_data(adv_input_data);
    end
    
end

I also tried to define two input layers in the prototxt file to use the one at first and then the other one, etc, but it does not seem to work. Is it possible to do something similar with the Python interface?
Reply all
Reply to author
Forward
0 new messages