You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to load a pre-built model and do batch scoring, I tried the following two ways, the first one can produce some results, and the second one compiles successfully but runs with segmentation fault. Could you please let me know which way I should follow, and why the second way doesn't work? Thanks!
method 1:
/* Image size and channels */
int width = 224;
int height = 224;
int channels = 3;
int batch_size = 5;
I am trying to load a pre-built model and do batch scoring, I tried the following two ways, the first one can produce some results, and the second one compiles successfully but runs with segmentation fault. Could you please let me know which way I should follow, and why the second way doesn't work? Thanks!
method 1:
Context ctx_dev(DeviceType::kCPU, 0);
map<string, NDArray> args_map;
map<string, NDArray> aux_map;
map<string, NDArray> parameters;
auto net = Symbol::Load("../Resnet/resnet-152-symbol.json");
auto data_iter = MXDataIter("ImageRecordIter")
.SetParam("path_imglist","../caltech_256/caltech-256-60-train.lst")
.SetParam("path_imgrec","../caltech_256/caltech-256-60-train.rec")
.SetParam("data_shape", Shape(3, 224, 224))
.SetParam("batch_size", batch_size)
.SetParam("shuffle", 1)
.CreateDataIter();
while(data_iter.Next()){
auto batch = data_iter.GetData();
args_map["data"] = batch;
auto *exec = net.SimpleBind(ctx_dev, args_map);
exec->Forward(false);
auto outputs = exec->outputs[0].Copy(Context(kCPU, 0));
NDArray::WaitAll();
for (int i = 0; i <2; i++) {
cout << outputs.At(0, i) <<",";
}
cout << endl;
}
MXNotifyShutdown();
method 2:
int width = 224;
int height = 224;
int channels = 3;
int batch_size = 5;
while(data_iter.Next()){
auto batch = data_iter.GetDataBatch();
batch.data.CopyTo(&args_map["data"]);
batch.label.CopyTo(&args_map["label"]);
exec->Forward(false);
NDArray::WaitAll();
}
The text was updated successfully, but these errors were encountered: