batch scoring in cpp
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 30/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- cpp
- Ambito
- machine-learning
Direzione di ricerca
Iniziate riproducendo i due percorsi descritti nell’issue con i file dei simboli e dei parametri ResNet, quindi tracciate le chiamate C++ NDArray::Load, Symbol::SimpleBind e di configurazione dell’executor utilizzate da ciascun metodo. Confrontate le mappe degli argomenti risultanti e la gestione dei batch, e definite come completato l’identificare la causa del segmentation fault e il documentare quale approccio di batch-scoring è valido e perché.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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;
Context ctx_dev(DeviceType::kCPU, 0);
map<string, NDArray> args_map;
map<string, NDArray> aux_map;
map<string, NDArray> parameters;
NDArray::Load("../Resnet/resnet-152-0000.params", 0, ¶meters);
for (const auto &k : parameters) {
if (k.first.substr(0, 4) == "aux:") {
auto name = k.first.substr(4, k.first.size() - 4);
aux_map[name] = k.second.Copy(ctx_dev);
}
if (k.first.substr(0, 4) == "arg:") {
auto name = k.first.substr(4, k.first.size() - 4);
args_map[name] = k.second.Copy(ctx_dev);
}
}
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;
Context ctx_dev(DeviceType::kCPU, 0);
map<string, NDArray> args_map;
map<string, NDArray> aux_map;
args_map["data"] = NDArray(Shape(batch_size, channels, width, height), ctx_dev);
args_map["label"] = NDArray(Shape(batch_size), ctx_dev);
auto net = Symbol::Load("../Resnet/resnet-152-symbol.json");
auto *exec = net.SimpleBind(ctx_dev, args_map);
NDArray::Load("../Resnet/resnet-152-0000.params", 0, &args_map);
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.GetDataBatch();
batch.data.CopyTo(&args_map["data"]);
batch.label.CopyTo(&args_map["label"]);
exec->Forward(false);
NDArray::WaitAll();
}
delete exec;
MXNotifyShutdown();
- Lingua principale
- C++
- Stelle
- 113
- Fork
- 78
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di dmlc/MXNet.cpp
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
-
Params interface question Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
-
GPU NDarray memory Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
-
saving/loading models Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
Tutte le issue di dmlc/MXNet.cpp
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
games-on-whales/wolf#509 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
bug-unconfirmed
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100