Shuffle Inputs to Keras Model Independently

41 views Asked by At

I'm training a CNN to classify time series of two different lengths, 40 timesteps and 80 timesteps. I've created a Siamese Neural Network to train the network on both at the same time (as I cannot create a batch of two different size inputs). I'm trying to shuffle the inputs separately at each epoch, so that a 40 timestep sequence doesn't end up with the same 80 timestep sequence every time (the built in model.fit(shuffle = True) permutes the inputs in the same order).

This is what I'm doing right now:

for q in range(NUM_EPOCHS):
    print(f'Epoch {q}...')

    pTrain = np.random.permutation(len(XTrain80))

    model.fit([XTrain80, XTrain40[pTrain]], [yTrain80, yTrain40[pTrain]], epochs = 1, shuffle = True)

Is there a better way to do this, preferably on one line?

Any and all help would be greatly appreciated.

0

There are 0 answers