简体   繁体   English

使用mxnet CNN模型进行预测

[英]Make a prediction using mxnet CNN model

Hi I'm a newbie to data science, I followed this tutorial https://mxnet.incubator.apache.org/tutorials/nlp/cnn.html but I am confused over how to make a single prediction using the trained model generated by the above mentioned tutorial. 嗨,我是数据科学的新手,我按照本教程https://mxnet.incubator.apache.org/tutorials/nlp/cnn.html但我很困惑如何使用生成的训练模型进行单一预测上面提到的教程。 Please guide me the right direction to fix this. 请指导我正确的方向来解决这个问题。 Thanks. 谢谢。

Here is a tutorial of how to predict with pretrained model: https://mxnet.incubator.apache.org/tutorials/python/predict_image.html 以下是如何使用预训练模型进行预测的教程: https ://mxnet.incubator.apache.org/tutorials/python/predict_image.html

Steps: 脚步:
1. Load pretrained model and create a MXNet module instance. 1.加载预训练模型并创建MXNet模块实例。
2. Grab your data and run forward with module 2.抓取您的数据并继续使用模块

One can load the model like this: 可以像这样加载模型:

sym, arg_params, aux_params = mx.model.load_checkpoint('cnn', 3)
mod = mx.mod.Module(symbol=sym, context=mx.cpu(), label_names=None)
mod.bind(for_training=False, data_shapes=[('data', (50,56))], 
         label_shapes=mod._label_shapes)
mod.set_params(arg_params, aux_params, allow_missing=True)

But unfortunately, you cannot use this for making only one prediction. 但不幸的是,你不能用它来做一个预测。 You would need a batch of 50. 你需要一批50。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM