Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

Fri Sep 28 21:59:51 2018[1,7]<stderr>:F0928 21:59:51.491448 3117 MemoryHandle.cpp:49] Check failed: size != 0 allocate 0 bytes

Open CruiseSun opened this issue 8 years ago • 5 comments

`def train_mapper(sample): ''' map image path to type needed by model input layer for the training set ''' global images_path_dic, feature_dic

img_name, features, label = sample

#create image data
img = paddle.image.load_image("./images/" + images_path_dic[img_name] + "/" + img_name)
if img is None:
    if os.path.getsize("./images/" + images_path_dic[img_name] + "/" + img_name) == 0:
        img = np.zeros((3, 152, 128))
    else:
        img = Image.open("./images/" + images_path_dic[img_name] + "/" + img_name)
        img = np.array(img.convert("RGB"))
img = paddle.image.simple_transform(img, 152, 128, True)

#create one-hot
features = features.strip().split(' ')

usrinfo = [[] for i in range(48)]

usrinfo[0] = img.flatten().astype('float32')

for feature_slot in features:
    feature_slot = feature_slot.strip()
    feature = feature_slot.rstrip(string.digits)[:-1]
    slot = feature_slot.strip().split(':')[-1]
    if 1 <= int(slot) <= 47:
        if feature in feature_dic[int(slot) - 1].keys():
            usrinfo[int(slot)].append(feature_dic[int(slot) - 1][feature])
        else:
            usrinfo[int(slot)].append(feature_dic[int(slot) - 1]["Other"])

for i in range(47):
    usrinfo[i+1] = sorted(set(usrinfo[i+1]))

usrinfo.append([float(label)])
# print len(usrinfo[0]), ', ', len(usrinfo[48])
return usrinfo`

CruiseSun avatar Sep 29 '18 03:09 CruiseSun

我的数据格式是<图片名称,其他样本特征,标签>,样本特征的形式是***:*的序列形式

CruiseSun avatar Sep 29 '18 03:09 CruiseSun

num_slot = 47
    concat_fc_slot = []
    for i in range(num_slot):
        input_feature = paddle.layer.data(name="data_slots_%d" % (i + 1),
                                          type=paddle.data_type.integer_value_sequence(len(feature_dict[i])))

        feature_emb = paddle.layer.embedding(
            input=input_feature,
            size=8,
            param_attr=_create_emb_attr("emb_slots_%d" % (i + 1)))

        feature_avg = paddle.layer.pooling(
            input=feature_emb,
            pooling_type=paddle.pooling.Avg())
      
        cat_fc_slot.append(feature_avg)

CruiseSun avatar Sep 29 '18 03:09 CruiseSun

根据日志和code初步判断可能为以下原因:

  1. input的某个batch为空
  2. 某个batch的某个feature为空

可以尝试以下方式单机试验排查下: 在python package-sites下找到文件dataprovider_converter.py并在这一行 之前print log, 看下在异常出现之前,读的dat是否为空,each_sample是否缺失了某个特征。

wanghaoshuang avatar Sep 29 '18 05:09 wanghaoshuang

您好,此issue若已经解决,我们将于三天内关闭。若在关闭后您仍需跟进 提问,可重新开启此问题, 我们将在24小时内回复您。因关闭带来的不便我们深表歉意,请您谅解~感谢您对PaddlePaddle的支持!

lucywsq avatar Oct 26 '18 07:10 lucywsq

该用户应该已经在线下沟通解决了该问题。。

wanghaoshuang avatar Nov 01 '18 12:11 wanghaoshuang