From 5ae34fb9ac47553a08e09ae4ac3fa0fbcd6f062a Mon Sep 17 00:00:00 2001 From: minqiyang Date: Tue, 9 Oct 2018 12:54:39 +0800 Subject: [PATCH] Make code more compatible --- python/paddle/dataset/flowers.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/paddle/dataset/flowers.py b/python/paddle/dataset/flowers.py index 4b4415397ff..313f580280d 100644 --- a/python/paddle/dataset/flowers.py +++ b/python/paddle/dataset/flowers.py @@ -39,6 +39,7 @@ import six import scipy.io as scio from paddle.dataset.image import * from paddle.reader import * +from paddle import compat as cpt import os import numpy as np from multiprocessing import cpu_count @@ -126,9 +127,11 @@ def reader_creator(data_file, batch = pickle.load(f) else: batch = pickle.load(f, encoding='bytes') - data = batch[six.b('data')] - labels = batch[six.b('label')] - for sample, label in zip(data, batch[six.b('label')]): + if batch is not None: + batch = cpt.to_text(batch) + data = batch['data'] + labels = batch['label'] + for sample, label in zip(data, batch['label']): yield sample, int(label) - 1 if not cycle: break -- GitLab