Decomposition Prerequisites
Restrictions
If a Conv2D layer uses a large shape, the decomposition will be time-consuming or terminated abnormally. To prevent this problem, refer to the following before starting decomposition:
- Reference performance specifications of the decomposition tool:
- CPU: Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
- At least 512 GB memory
Time taken to decompose a single Convolution layer:
- About 25s for shape (512, 512, 5, 5).
- About 16s for shape (1024, 1024, 3, 3).
- About 78s for shape (1024, 1024, 5, 5).
- About 63s for shape (2048, 2048, 3, 3).
- About 430s for shape (2048, 2048, 5, 5).
- Memory consideration:
It takes about 32 GB memory to decompose the Convolution kernel with shape (2048, 2048, 5, 5).
Prerequisites
Upload the TensorFlow model file to be decomposed and its weight files to any directory on the Linux server. The model file is a .meta file, and the weight file consists of a .data-0000X-of-0000X file and an .index weight file index. (The .data-0000X-of-0000X weight file and the .index weight file index are used in pair.)
This following uses the training script to generate a model file and the weight files (.data-0000X-of-0000X and .index).
- Prepare a training dataset.
- If the server installed with the AMCT has Internet access:
Create a dataset directory in the sample/tensor_decompose/ directory on the server, for example, data/mnist.
When the script is executed in 2, the training and test datasets are automatically downloaded to the data/mnist directory from http://yann.lecun.com/exdb/mnist/.
- If the user environment has no Internet access:
On a server with Internet access, visit the following links to download the corresponding packages and upload them to the sample/tensor_decompose/data/mnist directory on the AMCT server. (If the data/mnist directory does not exist, create it first.)
- The MNIST training dataset is available at: http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
- The label file of the MNIST training dataset is available at: http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz
- The MNIST test dataset is available at: http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz
- The label file of the MNIST test dataset is available at: http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz
- If the server installed with the AMCT has Internet access:
- Execute the training script to generate the model file and weight files.
The sample/tensor_decompose directory provides two copies of TensorFlow training code, one using the Session API and the other using the Estimator API. You can select one that best suits your needs. Go to the sample/tensor_decompose/ directory and run the following commands to generate the model file and weight files:
python3.7.5 train_sample_session.py --data_path DATA_PATH
Alternatively,
python3.7.5 train_sample_estimator.py --data_path DATA_PATH
--data_path is a required option that specifies the directly of the MNIST dataset, which can be absolute or relative.
An example is as follows:
python3.7.5 train_sample_session.py --data_path=data/mnist
If messages similar to the following are displayed, the execution is successful:
Valid Accuracy: 0.9803 // Training accuracy based on the MNIST dataset
- After the execution is successful, the model file and its weight files are generated in the sample/tensor_decompose/checkpoints directory. The following is an example.
-rw-r--r-- 1 amct amct 85 Jul 28 04:37 checkpoint //Checkpoint when the TensorFlow model file is generated -rw-r--r-- 1 amct amct 10633856 Jul 28 04:37 model.ckpt-200.data-00000-of-00001 //TensorFlow weight file -rw-r--r-- 1 amct amct 771 Jul 28 04:37 model.ckpt-200.index //Index of the TensorFlow weight file -rw-r--r-- 1 amct amct 60937 Jul 28 04:37 model.ckpt-200.meta //TensorFlow model file