if isinstance(event, fluid.contrib.trainer.EndEpochEvent):
# save parameters
trainer.save_params(params_dirname)
...
...
@@ -390,7 +390,7 @@ Usually, with MNIST data, the softmax regression model achieves an accuracy arou
## Application
After training, users can use the trained model to classify images. The following code shows how to inference MNIST images through `fluid.Inferencer`.
After training, users can use the trained model to classify images. The following code shows how to inference MNIST images through `fluid.contrib.inferencer.Inferencer`.
### Create Inferencer
...
...
@@ -398,7 +398,7 @@ The `Inferencer` takes an `infer_func` and `param_path` to setup the network and
We can simply plug-in the classifier defined earlier here.
```python
inferencer = fluid.Inferencer(
inferencer = fluid.contrib.inferencer.Inferencer(
# infer_func=softmax_regression, # uncomment for softmax regression
# infer_func=multilayer_perceptron, # uncomment for MLP
infer_func=convolutional_neural_network, # uncomment for LeNet5
if isinstance(event, fluid.contrib.trainer.EndEpochEvent):
# save parameters
trainer.save_params(params_dirname)
...
...
@@ -432,7 +432,7 @@ Usually, with MNIST data, the softmax regression model achieves an accuracy arou
## Application
After training, users can use the trained model to classify images. The following code shows how to inference MNIST images through `fluid.Inferencer`.
After training, users can use the trained model to classify images. The following code shows how to inference MNIST images through `fluid.contrib.inferencer.Inferencer`.
### Create Inferencer
...
...
@@ -440,7 +440,7 @@ The `Inferencer` takes an `infer_func` and `param_path` to setup the network and
We can simply plug-in the classifier defined earlier here.
```python
inferencer = fluid.Inferencer(
inferencer = fluid.contrib.inferencer.Inferencer(
# infer_func=softmax_regression, # uncomment for softmax regression
# infer_func=multilayer_perceptron, # uncomment for MLP
infer_func=convolutional_neural_network, # uncomment for LeNet5
# Test against with the test dataset to get accuracy.
avg_cost,accuracy=trainer.test(
reader=test_reader,feed_order=['pixel','label'])
...
...
@@ -474,7 +474,7 @@ Figure 12. The error rate of VGG model on CIFAR10
## Application
After training is completed, users can use the trained model to classify images. The following code shows how to infer through `fluid.Inferencer` interface. You can uncomment some lines from below to change the model name.
After training is completed, users can use the trained model to classify images. The following code shows how to infer through `fluid.contrib.inferencer.Inferencer` interface. You can uncomment some lines from below to change the model name.
### Generate input data for inferring
...
...
@@ -512,7 +512,7 @@ We can simply plug-in the inference_program defined earlier here.
@@ -516,7 +516,7 @@ Figure 12. The error rate of VGG model on CIFAR10
## Application
After training is completed, users can use the trained model to classify images. The following code shows how to infer through `fluid.Inferencer` interface. You can uncomment some lines from below to change the model name.
After training is completed, users can use the trained model to classify images. The following code shows how to infer through `fluid.contrib.inferencer.Inferencer` interface. You can uncomment some lines from below to change the model name.
### Generate input data for inferring
...
...
@@ -554,7 +554,7 @@ We can simply plug-in the inference_program defined earlier here.