Keras:model.fit_generator运行良好,然后崩溃了

时间:2019-06-26 18:50:49

标签: python keras keras-2

opt/conda/lib/python3.6/site-packages/keras/callbacks.py in on_batch_end(self, batch, logs)
    234             else:
    235                 if k in self.totals:
--> 236                     self.totals[k] += v * batch_size
    237                 else:
    238                     self.totals[k] = v * batch_size

ValueError: operands could not be broadcast together with shapes (32,) (20,) (32,) 

此错误在培训过程中突然出现-似乎在批处理结束时。任何机构都有指向此处指的是什么形状的指针吗?

每个Kyle的请求:

class batch_creator(Sequence):

    def __init__(self, data, batch_size,window_size, V):
        self.data = data

        self.batch_size = batch_size

    def __len__(self):
        return int(len(self.data) / float(self.batch_size))

    def __getitem__(self, idx):
        batch_x = self.data[idx*self.batch_size :(idx +1)* self.batch_size]

        #if idx % self.batch_size==0:
        #print(idx)
        #words=[]
       # contexts=[]

        x,z,y =next(generate_data(batch_x, window_size, V))

        x = np.array(x,dtype=np.int32)
        z = np.array(z,dtype=np.int32)
        y= np.array(y,dtype=np.int32)
        #print(x)
        return [x,y]

"""Instantiate Batchmanager"""
model.fit_generator(batch_manager,epochs=5)

0 个答案:

没有答案