How to train the MLP Deep Learning Model
Prerequisites
There are 2 prerequisites to training the MLP Deep Learning Model:
Download and Install Anaconda
- Please download and install Anaconda from its website
Install Dependencies
Run the following commands to install the necessary dependencies:
Install numpy: conda install numpy
Install tensorflow: conda install tensorflow
Install keras (version 1.2.2): conda install -c conda-forge keras=1.2.2
Install h5py: conda install h5py
* Install protobuf: conda install -c conda-forge protobuf
Train the Model
The following steps are to be followed in order to train the MLP model using the released demo data. For convenience, we denote APOLLO as the path of the local apollo repository, for example, /home/username/apollo
-
Create a folder to store offline prediction data using the command
mkdir APOLLO/data/predictionif it does not exist -
Open
apollo/modules/prediction/conf/prediction.conf. Turn on the off-line mode by changing--noprediction_offline_modeto--prediction_offline_mode -
Start dev docker using
bash docker/scripts/dev_start.shunder the apollo folder -
Enter dev docker using
bash docker/scripts/dev_into.shunder apollo folder -
In docker, under
/apollo/, runbash apollo.sh buildto compile -
In docker, under
/apollo/, download the demo ROSbag bypython docs/demo_guide/rosbag_helper.py demo_2.0.bag -
In docker, under
/apollo/, run prediction module bybash scripts/prediction.sh start_fe -
Open a new terminal window, enter the apollo dev docker using Step 4
-
In the new terminal window, under
/apollo/, play the demo rosbag usingrosbag play demo_2.0.bag -
After the demo ROSbag finishes running in the new terminal window, go to the old terminal window and stop the prediction module by pressing
Ctrl + C -
Checkout if there is a file called
feature.0.binunder the folder/apollo/data/prediction/ -
In docker, go to
/apollo/modules/tools/prediction/mlp_train/, label the data usingpython generate_labels.py -f /apollo/data/prediction/feature.0.bin. Then check if there is a file calledfeature.0.label.binunder the folder/apollo/data/prediction/
Update: In docker, go to
/apollo/modules/tools/prediction/mlp_train/, label the data usingpython generate_labels.py /apollo/data/prediction/feature.0.bin /apollo/data/prediction/feature.0.label.bin. Then check if there is a file calledfeature.0.label.binunder the folder/apollo/data/prediction/
- In docker, under
/apollo/modules/tools/prediction/mlp_train/, generate H5 files usingpython generate_h5.py -f /apollo/data/prediction/feature.0.label.bin. Then check if there is a file calledfeature.0.label.h5created
Update: In docker, under
/apollo/modules/tools/prediction/mlp_train/, generate H5 files usingpython generate_h5.py /apollo/data/prediction/feature.0.label.bin /apollo/data/prediction/feature.0.label.h5. Then check if there is a file calledfeature.0.label.h5created
-
Exit dev docker
-
Go to the folder
APOLLO/modules/tools/prediction/mlp_train/proto/runprotoc --python_out=./ fnn_model.prototo generate fnn_model_pb2.py -
Go to the folder
APOLLO/modules/tools/prediction/mlp_train/, run the training model usingpython mlp_train.py APOLLO/data/prediction/feature.0.label.h5 -
The model's evaluation report will be in the file
APOLLO/modules/tools/prediction/mlp_train/evaluation_report.log -
The model will be stored in the binary file
APOLLO/modules/tools/prediction/mlp_train/mlp_model.bin, which can replace the old model inAPOLLO/modules/prediction/data/mlp_vehicle_model.binif you think that's better