Quick Start in 3 Minutes
With OneFlow installed, you can run the following command to download mlp_mnist.py python script from and run it.
The output looks like below:
Epoch [1/20], Loss: 0.7955
Epoch [1/20], Loss: 0.4653
Epoch [1/20], Loss: 0.2064
Epoch [1/20], Loss: 0.2683
...
The output is a series of numbers representing the loss values while training. The goal of training is to make the loss value as small as possible. So far, you have completed a full neural network training by using OneFlow.
The following is the full code.
The next section is a brief description of this code.
A special feature of OneFlow compares to other deep learning frameworks is:
@flow.global_function(type="train")
def train_job(
labels: tp.Numpy.Placeholder((BATCH_SIZE,), dtype=flow.int32),
) -> tp.Numpy:
The parameter type
is used to specify the type of job: type="train"
means it’s a training job and type="predict"
means evaluation or prediction job.
In OneFlow, a neural network training or prediction task needs two pieces of information:
One part is the structure of neural network and its related parameters. These are defined in the job function which mentioned above.
The other part is the configuration of training to the network. For example, and type of model optimizer. These are defined by code as below:
Besides the job function definition and configuration which mentioned above, code in this script contains all the points of how to train a neural network.
print(..., loss.mean())
: print loss values for every 20 iterations.
This page is just a simple example on neural network. A more comprehensive and detailed introduction of OneFlow can be found in Convolution Neural Network for Handwriting Recognition.
In addition, you can refer to to learn more about how to use OneFlow for deep learning.
Benchmarks and related scripts for some prevalent networks are also provided in repository OneFlow-Benchmark.
- Getting stuck when running this script
Then try again
- My computer can’t connect to the Internet and keeps getting stuck when I run the script.
Please activate JavaScript for write a comment in LiveRe