2016-08-17 2 views
3

Ich weiß, wenn ich die Eingabeebene wie folgt habe, nimmt mein Netzwerk Blobs der Dimension (1,1,100,100).Caffe variable Losgröße

layer { 
    name: "data" 
    type: "Input" 
    top: "data" 
    input_param { 
    shape { 
     dim: 1 
     dim: 1 
     dim: 100 
     dim: 100 
    } 
    } 
} 

Was soll ich tun, um die erste Dimension (Input Batch Size) variabel zu machen? damit ich die Netzwerk-Chargen unterschiedlicher Größe einspeisen kann?

+1

I in Funktion denken 'Net :: Forward ( const Vektor *> & Boden, D-Typ * Verlust)', ändern nur 'net_input_blobs_ [i] -> CopyFrom (* bottom [i]); 'zu' net_input_blobs_ [i] -> CopyFrom (* bottom [i], false, true); 'kann helfen, was die Eingabe entsprechend dem' bottom umformt 'Blob-Form. – Dale

+0

@DaleSong vielen Dank – dontloo

Antwort

3

Sie können das Netzwerk vor dem Aufruf der forward()-Methode umformen. Wenn Sie also eine Variable batch_size haben möchten, sollten Sie sie jedes Mal neu gestalten. Dies kann in jeder Schnittstelle geschehen, die Sie verwenden (C, Python, MATLAB).

In Python, geht es wie folgt aus:

net.blobs['data'].reshape(BATCH_SIZE, CHANNELS, HEIGHT, WIDTH) 
net.reshape() 
net.forward() 

Hinweis: Ich glaube, net.reshape() optional ist und das Netzwerk nennt dies vor der Vorwärts Aktion ausführt.

+0

Ich fand dies ein hilfreiches Tutorial für Caffe: http://christopher5106.github.io/deep/learning/2015/09/04/Deep-learning-tutorial-on-Caffe-Technology.html – AHA

0

zusätzlich zu AHA Antwort, in C++ ist es wie

Blob<float>* input_layer = net_->input_blobs()[0]; 
input_layer->Reshape(batch_size, input_layer->shape(1), input_layer->shape(2), input_layer->shape(3)); 
net_->Reshape();