-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Image classification new api markdown #542
Image classification new api markdown #542
Conversation
daming-lu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some tiny comments 😬
| global step | ||
| if isinstance(event, paddle.event.EndIteration): | ||
| if isinstance(event, fluid.EndStepEvent): | ||
| if step % 1 == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should change step % 1 == 0 to something more meaningful, say step % 10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we remove this line? Looks like we should draw it no matter what.
| cost_ploter.plot() | ||
| step += 1 | ||
| if isinstance(event, paddle.event.EndPass): | ||
| if isinstance(event, fluid.EndEpochEvent): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curious at the last step of an epoch, will Fluid trigger both EndStepEvent and EndEpochEvent ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the order is
EndStepEvent, and then EndEpochEvent
03.image_classification/README.cn.md
Outdated
| # 而PIL打开图片默认通道顺序为RGB,因为需要交换通道。 | ||
| im = im[(2, 1, 0),:,:] # BGR | ||
| im = im.flatten() | ||
| # The storage order of the loaded image is W(widht), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
W(width)
03.image_classification/README.cn.md
Outdated
| # the CHW order, so transpose them. | ||
| im = im.transpose((2, 0, 1)) # CHW | ||
| # In the training phase, the channel order of CIFAR | ||
| # image is B(Blue), G(green), R(Red). But PIL open |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PIL opens
| lab = np.argsort(-probs) # probs and lab are the results of one batch data | ||
| print "Label of image/dog.png is: %d" % lab[0][0] | ||
| ``` | ||
| `Inferencer` 需要一个 `infer_func` 和 `param_path` 来设置网络和经过训练的参数。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kind of weird that we call the param name param_path but use params_dirname as the variable name 😭
param_path=params_dirname
But let's keep it as-is for now.
03.image_classification/README.md
Outdated
| Firstly, we create the model parameters according to the previous model configuration `cost`. | ||
| In the context of supervised learning, labels of training images are defined in `fluid.layers.data` as well. During training, the cross-entropy loss function is used and the loss is the output of the network. During testing, the outputs are the probabilities calculated in the classifier. | ||
|
|
||
| **NOTE:** A train program should return an array and the first return argument has to be `avg_cost`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first returned ; The trainer always implicitly uses
| global step | ||
| if isinstance(event, paddle.event.EndIteration): | ||
| if isinstance(event, fluid.EndStepEvent): | ||
| if step % 1 == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here. step %10 might make more sense 😆
03.image_classification/README.md
Outdated
|
|
||
| ### Generate input data for inferring | ||
|
|
||
| `dog.png` is an example image of a dog. Turn it into an numpy array to match the data feeder format. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a numpy array
03.image_classification/README.md
Outdated
| im = im.resize((32, 32), Image.ANTIALIAS) | ||
|
|
||
| im = np.array(im).astype(np.float32) | ||
| # The storage order of the loaded image is W(widht), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
width
Update the English and Chinese Image Classification tutorial with high level fluid API