|
| 1 | +# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +import numpy as np |
| 16 | +import paddle |
| 17 | +import paddle.fluid as fluid |
| 18 | +import paddle.dataset.flowers as flowers |
| 19 | + |
| 20 | +batch_size = 12 |
| 21 | +data_shape = [3, 224, 224] |
| 22 | + |
| 23 | +with fluid.program_guard(fluid.Program(), fluid.Program()): |
| 24 | + reader = paddle.batch(flowers.train(), batch_size=batch_size) |
| 25 | + feeder = fluid.DataFeeder( |
| 26 | + feed_list=[ # order is image and label |
| 27 | + fluid.layers.data( |
| 28 | + name='image', shape=data_shape, dtype='float32'), |
| 29 | + fluid.layers.data( |
| 30 | + name='label', shape=[1], dtype='int64'), |
| 31 | + ], |
| 32 | + place=fluid.CPUPlace()) |
| 33 | + fluid.recordio_writer.convert_reader_to_recordio_file( |
| 34 | + './flowers_bs_12_3_224_224.recordio', reader, feeder) |
0 commit comments