一种训练中feed data的方式记录

def generate_arrays():
while 1:
global X,Y
for j in range(1, 7, 1):
for i in range(0, 200000, 200):
if i % 10000 == 0:
seq_dir = '../dataset1/data/seq_' + str(j) + '' + str(i) + '.npy'
label_dir = '../dataset1/data/label
' + str(j) + '_' + str(i) + '.npy'
X = np.load(seq_dir)
Y = np.squeeze(np.load(label_dir).astype(np.int32))
X = np.expand_dims(X, axis=-1).astype(np.float32)
X = X[:,:,0:1200,:]
Y = tf.keras.utils.to_categorical(Y, num_classes=3, dtype='float32')
number_of_sequence = X.shape[0]
index = np.arange(number_of_sequence)
np.random.shuffle(index)
X = X[index[:]]
Y = Y[index[:]]
begin_idx = i % 10000
end_idx = begin_idx + 200
yield (X[begin_idx:end_idx], Y[begin_idx:end_idx])

model.fit(x = generate_arrays(), steps_per_epoch=30000, epochs=60,
validation_data=(valid_data, valid_label), validation_freq=1, callbacks=[callback1, reduce_lr, callback2], verbose=2, shuffle=True)

你可能感兴趣的:(一种训练中feed data的方式记录)