Ich ändere ein C++ Beispiel in mxnet. Ich verstehe nicht, wie ein NDArray-Objekt zugewiesen wird. Es gibt keine grundlegende Dokumentation, was ziemlich frustrierend ist.Wie NDArray in C++ API verwenden?
Ich versuche, ein NDArray zuzuordnen, aber durch die Deklaration einer Instanz scheint es die Daten nicht zuzuordnen, nur wenn ich ein Array mit Daten fülle. Ist das korrekt?
// this code snippet does not work
NDArray a = NDArray(Shape(10, 20), Context::cpu());
const float *dat = a.GetData();
float result = *dat; // read memory violation
result = *(dat + 10);
// this code snippet works
NDArray b = NDArray(Shape(10, 20), Context::cpu());
a.SampleUniform(1.0, 2.0, &b);
const float *dat2 = b.GetData();
float result2 = *dat2; // works!!
result2 = *(dat2 + 10);
Hat jemand Erfahrung mit der C++ API und ändernden Netzwerken?
Haben Sie den Beispielcode https://github.com/apache/incubator-mxnet/tree/master/example/image-classification/predict-cpp gesehen? – leezu