In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "how to get started with MMdnn quickly", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to get started with MMdnn" article.
MMdnn is an open source tool from Microsoft to help users interoperate between different deep learning frameworks, including model transformation and visualization. Currently, model transformation between Caffe, Keras, MXNet, Tensorflow, CNTK, PyTorch, and CoreML frameworks is supported.
Installation
Get the stable version of MMdnn from the following command line:
Pip install https://github.com/Microsoft/MMdnn/releases/download/0.1.3/mmdnn-0.1.3-py2.py3-none-any.whl
Or try the latest version with the following command:
Pip install-U git+ https://github.com/Microsoft/MMdnn.git@master model transformation
There are a large number of existing frameworks in the industry and academic circles, which are suitable for developers and researchers to design models. Each framework has its own network structure definition and model preservation format. The gap between frameworks hinders the interaction of models.
We provide a model converter to help developers transform models through intermediate representation formats to suit different frameworks.
Supporting framework
Each supported framework has detailed README documentation, which can be found in the following conversion folders.
Test model
We have tested the currently supported inter-framework model transformation functions on some ImageNet models.
Framework under testing: model being tested by PyTorch CNTK Caffe2 ONNX: RNN Image style Migration Target Detection
Model visualization
You can use the MMdnn Model Visualization tool (http://vis.mmdnn.com/) to submit your own IR json file for model visualization. To run the following command line, you need to install requests, Keras, TensorFlow using your favorite package manager.
Use the Keras inception_v3 model as an example.
\ 1. Download the pre-training model:
Python-m mmdnn.conversion.examples.keras.extract_model-n inception_v3
\ 2. Convert the pre-training model file to an intermediate representation format:
Python3-m mmdnn.conversion._.convertToIR-f keras-d keras_inception_v3-n imagenet_inception_v3.json
\ 3. Open the MMdnn model visualization tool address (http://mmdnn.eastasia.cloudapp.azure.com:8080/) and select the file keras_inception_v3.json.
Community support
This project is still under development and exploration, and it requires readers to improve the framework of intermediate representation and support. Therefore, the author of the project said that he would very much like to have developers to provide new operations or extensions.
Intermediate representation: the intermediate token stores the network architecture in the protobuf binary file and the training weight in the NumPynative format. In addition, the current IR weight data is in NHWC format. For details of the intermediate representation, please see the ops.txt and graph.proto files. Framework: we are extending to other framework versions and visualization tools such as Caffe2, PyTorch, and CoreML. In addition, the project is also actively developing RNN-related operation methods.
Use case
The following is a basic example of the framework transformation of the project, including official tutorials and user-provided cases, and Machine Heart briefly introduces the official Keras-to-CNTK conversion tutorial. Official tutorial:
Keras "inception_v3" to CNTK user case:
MXNet "resnet 152 11k" to PyTorch MXNet "resnext" to Keras Tensorflow "resnet 101" to PyTorch Tensorflow "mnist mlp model" to CNTK Tensorflow "Inception_v3" to MXNet Caffe "AlexNet" to Tensorflow Caffe "inception_v4" to Tensorflow Caffe "VGG16_SOD" to Tensorflow Caffe "Squeezenet v1.1" to CNTK
Transformation from Keras "inception_v3" Model to CNTK
1. Install Keras and CNTK
Pip install keraspip install https://cntk.ai/PythonWheel/CPU-Only/cntk-2.3-cp27-cp27mu-linux_x86_64.whl
Or
Pip install https://cntk.ai/PythonWheel/CPU-Only/cntk-2.3-cp35-cp35m-linux_x86_64.whl
two。 Prepare the Keras model
The following example will first download the pre-training model and then use a simple model extractor to retrieve the model from the Keras application, which will extract the Keras model schema and weights.
$python-m mmdnn.conversion.examples.keras.extract_model-n inception_v3Using TensorFlow backend.Downloading data from https://github.com/fchollet/deep-learning-models/releases/download/v0.5/inception_v3_weights_tf_dim_ordering_tf_kernels.h696075776/96112376 [= >.]-ETA: 0s...Network structure is saved as [imagenet_inception_v3.json]. Network weights are saved as [imagenet_inception_v3.h6].
The schema file imagenet_inception_v3.json and the weight file imagenet_inception_v3.h6 are downloaded to the current working directory.
3. Convert the pre-training model file to intermediate representation
$python-m mmdnn.conversion._.convertToIR-f keras-d converted-n imagenet_inception_v3.json-w imagenet_inception_v3.h6Using TensorFlow backend....Network file [imagenet_inception_v3.json] is loaded successfully.IR network structure is saved as [converted.json]. IR network structure is saved as [converted.pb]. IR weights are saved as [converted.npy].
The above command takes imagenet_inception_v3.json as the description file of the neural network architecture and imagenet_inception_v3.h6 as the pre-training weight. Then the intermediate signature file converted.json is calculated for visualization, and converted.proto and converted.npy are calculated for further conversion to other frameworks.
4. Convert IR files to CNTK models
$python-m mmdnn.conversion._.IRToCode-f cntk-d converted_cntk.py-n converted.pb-w converted.npyParse file [converted.pb] with binary format successfully.Target network code snippet is saved as [converted_cntk.py].
You will get the file converted_cntk.py, including the original CNTK code that builds the Inception V3 network.
After these three steps, you have converted the pre-trained Keras Inception_v3 model into CNTK network file converted_cntk.py and weight file converted.npy. You can use these two files to adjust training or inference.
5. Dump the original CNTK model
Python-m mmdnn.conversion.examples.cntk.imagenet_test-n converted_cntk-w converted.npy-- dump cntk_inception_v3.dnn...CNTK model file is saved as [cntk_inception_v3.dnn], generated by [converted_cntk.py] and [converted.npy].
CNTK can load the file cntk_inception_v3.dnn directly.
The above is about the content of this article on "how to get started with MMdnn quickly". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.