diff --git a/doc/fluid/user_guides/simple_case/image_classification/README.cn.md b/doc/fluid/user_guides/simple_case/image_classification/README.cn.md index ee7987c38502025aa5d97bf828b3eeafc9fe15da..cdc22a93b9ce9659744ef0a7be8a461606cb7ec2 100644 --- a/doc/fluid/user_guides/simple_case/image_classification/README.cn.md +++ b/doc/fluid/user_guides/simple_case/image_classification/README.cn.md @@ -315,8 +315,8 @@ def resnet_cifar10(ipt, depth=32): ```python def inference_program(): # The image is 32 * 32 with RGB representation. - data_shape = [3, 32, 32] - images = fluid.layers.data(name='pixel', shape=data_shape, dtype='float32') + data_shape = [None, 3, 32, 32] + images = fluid.data(name='pixel', shape=data_shape, dtype='float32') predict = resnet_cifar10(images, 32) # predict = vgg_bn_drop(images) # un-comment to use vgg net @@ -327,7 +327,7 @@ def inference_program(): 然后我们需要设置训练程序 `train_program`。它首先从推理程序中进行预测。 在训练期间,它将从预测中计算 `avg_cost`。 -在有监督训练中需要输入图像对应的类别信息,同样通过`fluid.layers.data`来定义。训练中采用多类交叉熵作为损失函数,并作为网络的输出,预测阶段定义网络的输出为分类器得到的概率信息。 +在有监督训练中需要输入图像对应的类别信息,同样通过`fluid.data`来定义。训练中采用多类交叉熵作为损失函数,并作为网络的输出,预测阶段定义网络的输出为分类器得到的概率信息。 **注意:** 训练程序应该返回一个数组,第一个返回参数必须是 `avg_cost`。训练器使用它来计算梯度。 @@ -335,7 +335,7 @@ def inference_program(): def train_program(): predict = inference_program() - label = fluid.layers.data(name='label', shape=[1], dtype='int64') + label = fluid.data(name='label', shape=[None,1], dtype='int64') cost = fluid.layers.cross_entropy(input=predict, label=label) avg_cost = fluid.layers.mean(cost) accuracy = fluid.layers.accuracy(input=predict, label=label) diff --git a/doc/fluid/user_guides/simple_case/image_classification/README.md b/doc/fluid/user_guides/simple_case/image_classification/README.md index 310733c1c2dad6efcf5e4abff876fcf72b29b0b4..6471b3398c19f89ead67342559d6fd6f7618d693 100644 --- a/doc/fluid/user_guides/simple_case/image_classification/README.md +++ b/doc/fluid/user_guides/simple_case/image_classification/README.md @@ -309,13 +309,13 @@ def resnet_cifar10(ipt, depth=32): ## Inference Program Configuration -The input to the network is defined as `fluid.layers.data` , corresponding to image pixels in the context of image classification. The images in CIFAR10 are 32x32 coloured images with three channels. Therefore, the size of the input data is 3072 (3x32x32). +The input to the network is defined as `fluid.data` , corresponding to image pixels in the context of image classification. The images in CIFAR10 are 32x32 coloured images with three channels. Therefore, the size of the input data is 3072 (3x32x32). ```python def inference_program(): # The image is 32 * 32 with RGB representation. - data_shape = [3, 32, 32] - images = fluid.layers.data(name='pixel', shape=data_shape, dtype='float32') + data_shape = [None, 3, 32, 32] + images = fluid.data(name='pixel', shape=data_shape, dtype='float32') predict = resnet_cifar10(images, 32) # predict = vgg_bn_drop(images) # un-comment to use vgg net @@ -326,7 +326,7 @@ def inference_program(): Then we need to set up the the `train_program`. It takes the prediction from the inference_program first. During the training, it will calculate the `avg_loss` from the prediction. -In the context of supervised learning, labels of training images are defined in `fluid.layers.data` as well. During training, the multi-class cross-entropy is used as the loss function and becomes the output of the network. During testing, the outputs are the probabilities calculated in the classifier. +In the context of supervised learning, labels of training images are defined in `fluid.data` as well. During training, the multi-class cross-entropy is used as the loss function and becomes the output of the network. During testing, the outputs are the probabilities calculated in the classifier. **NOTE:** A training program should return an array and the first returned argument has to be `avg_cost` . The trainer always uses it to calculate the gradients. @@ -335,7 +335,7 @@ The trainer always uses it to calculate the gradients. def train_program(): predict = inference_program() - label = fluid.layers.data(name='label', shape=[1], dtype='int64') + label = fluid.data(name='label', shape=[None, 1], dtype='int64') cost = fluid.layers.cross_entropy(input=predict, label=label) avg_cost = fluid.layers.mean(cost) accuracy = fluid.layers.accuracy(input=predict, label=label) diff --git a/doc/fluid/user_guides/simple_case/image_classification/index.cn.html b/doc/fluid/user_guides/simple_case/image_classification/index.cn.html index ffbf605eb9cbcd0c8e963b7703db1e5923ca4cc0..6c53ac5453c9d9cc13f63c8ccfd8a33c7b688d93 100644 --- a/doc/fluid/user_guides/simple_case/image_classification/index.cn.html +++ b/doc/fluid/user_guides/simple_case/image_classification/index.cn.html @@ -357,8 +357,8 @@ def resnet_cifar10(ipt, depth=32): ```python def inference_program(): # The image is 32 * 32 with RGB representation. - data_shape = [3, 32, 32] - images = fluid.layers.data(name='pixel', shape=data_shape, dtype='float32') + data_shape = [None, 3, 32, 32] + images = fluid.data(name='pixel', shape=data_shape, dtype='float32') predict = resnet_cifar10(images, 32) # predict = vgg_bn_drop(images) # un-comment to use vgg net @@ -369,7 +369,7 @@ def inference_program(): 然后我们需要设置训练程序 `train_program`。它首先从推理程序中进行预测。 在训练期间,它将从预测中计算 `avg_cost`。 -在有监督训练中需要输入图像对应的类别信息,同样通过`fluid.layers.data`来定义。训练中采用多类交叉熵作为损失函数,并作为网络的输出,预测阶段定义网络的输出为分类器得到的概率信息。 +在有监督训练中需要输入图像对应的类别信息,同样通过`fluid.data`来定义。训练中采用多类交叉熵作为损失函数,并作为网络的输出,预测阶段定义网络的输出为分类器得到的概率信息。 **注意:** 训练程序应该返回一个数组,第一个返回参数必须是 `avg_cost`。训练器使用它来计算梯度。 @@ -377,7 +377,7 @@ def inference_program(): def train_program(): predict = inference_program() - label = fluid.layers.data(name='label', shape=[1], dtype='int64') + label = fluid.data(name='label', shape=[None, 1], dtype='int64') cost = fluid.layers.cross_entropy(input=predict, label=label) avg_cost = fluid.layers.mean(cost) accuracy = fluid.layers.accuracy(input=predict, label=label) diff --git a/doc/fluid/user_guides/simple_case/image_classification/index.html b/doc/fluid/user_guides/simple_case/image_classification/index.html index aae792c4d11ba50b2f289d026a43d9f75c590443..66c1a657e2ee88463dbd1e4706109aaa7d67d554 100644 --- a/doc/fluid/user_guides/simple_case/image_classification/index.html +++ b/doc/fluid/user_guides/simple_case/image_classification/index.html @@ -351,13 +351,13 @@ def resnet_cifar10(ipt, depth=32): ## Inference Program Configuration -The input to the network is defined as `fluid.layers.data` , corresponding to image pixels in the context of image classification. The images in CIFAR10 are 32x32 coloured images with three channels. Therefore, the size of the input data is 3072 (3x32x32). +The input to the network is defined as `fluid.data` , corresponding to image pixels in the context of image classification. The images in CIFAR10 are 32x32 coloured images with three channels. Therefore, the size of the input data is 3072 (3x32x32). ```python def inference_program(): # The image is 32 * 32 with RGB representation. - data_shape = [3, 32, 32] - images = fluid.layers.data(name='pixel', shape=data_shape, dtype='float32') + data_shape = [None, 3, 32, 32] + images = fluid.data(name='pixel', shape=data_shape, dtype='float32') predict = resnet_cifar10(images, 32) # predict = vgg_bn_drop(images) # un-comment to use vgg net @@ -368,7 +368,7 @@ def inference_program(): Then we need to set up the the `train_program`. It takes the prediction from the inference_program first. During the training, it will calculate the `avg_loss` from the prediction. -In the context of supervised learning, labels of training images are defined in `fluid.layers.data` as well. During training, the multi-class cross-entropy is used as the loss function and becomes the output of the network. During testing, the outputs are the probabilities calculated in the classifier. +In the context of supervised learning, labels of training images are defined in `fluid.data` as well. During training, the multi-class cross-entropy is used as the loss function and becomes the output of the network. During testing, the outputs are the probabilities calculated in the classifier. **NOTE:** A training program should return an array and the first returned argument has to be `avg_cost` . The trainer always uses it to calculate the gradients. @@ -377,7 +377,7 @@ The trainer always uses it to calculate the gradients. def train_program(): predict = inference_program() - label = fluid.layers.data(name='label', shape=[1], dtype='int64') + label = fluid.data(name='label', shape=[None, 1], dtype='int64') cost = fluid.layers.cross_entropy(input=predict, label=label) avg_cost = fluid.layers.mean(cost) accuracy = fluid.layers.accuracy(input=predict, label=label) diff --git a/doc/fluid/user_guides/simple_case/image_classification/train.py b/doc/fluid/user_guides/simple_case/image_classification/train.py index 28bbceb36c8a8a131c686f54a1f8a3c4e5bc109c..09479180824a9008029dce77a1364f50e6ee0f17 100644 --- a/doc/fluid/user_guides/simple_case/image_classification/train.py +++ b/doc/fluid/user_guides/simple_case/image_classification/train.py @@ -40,8 +40,8 @@ def parse_args(): def inference_network(): # The image is 32 * 32 with RGB representation. - data_shape = [3, 32, 32] - images = fluid.layers.data(name='pixel', shape=data_shape, dtype='float32') + data_shape = [None, 3, 32, 32] + images = fluid.data(name='pixel', shape=data_shape, dtype='float32') predict = resnet_cifar10(images, 32) # predict = vgg_bn_drop(images) # un-comment to use vgg net @@ -49,7 +49,7 @@ def inference_network(): def train_network(predict): - label = fluid.layers.data(name='label', shape=[1], dtype='int64') + label = fluid.data(name='label', shape=[None, 1], dtype='int64') cost = fluid.layers.cross_entropy(input=predict, label=label) avg_cost = fluid.layers.mean(cost) accuracy = fluid.layers.accuracy(input=predict, label=label)