Hey everyone!
I’ve been trying to convert a set of 12 concurrent signals of length 512 each into a singular signal of length 100. I initially wanted to start with a simple Keras implementation as follows:
model = Sequential()
model.add(Conv1D(filters=16, kernel_size=5, strides=2, input_shape=(512, 12)))
model.add(LeakyReLU(alpha=0.05))
model.add(BatchNormalization())
model.add(Dropout(0.2))
model.add(Conv1D(filters=32, kernel_size=5, strides=2))
model.add(LeakyReLU(alpha=0.05))
model.add(BatchNormalization())
model.add(Dropout(0.2))
model.add(Conv1D(filters=64, kernel_size=5, strides=2))
model.add(LeakyReLU(alpha=0.05))
model.add(Flatten())
model.add(Dense(128))
model.add(LeakyReLU(alpha=0.05))
model.add(Dropout(0.5))
model.add(Dense(100, activation='tanh'))
model.compile(loss='mean_squared_error', optimizer=Adam(lr=1e-6))
history = model.fit(x, y, epochs=100, batch_size=32, verbose=1, validation_data=(x_val, y_val))
Now this model performs quite poorly*, so I wanted to attempt to use a pix2pix-style approach in PyTorch:
https://paste.rs/5Ff.py for model definitions
https://paste.rs/FXQ.py for training routine
For some reason, my PyTorch generator keeps producing extremely similar outputs:
netG.eval()
y_ = netG(x_val)
Obviously, the PyTorch pix2pix implementation is different from the simple Keras implementation, but even when I switch the criterion_reconstruction
to MSE, disable the loss obtained from the GAN (and simply use the raw reconstruction L1 or L2 loss), use the same optimizers, the same batch size, and same dataset, PyTorch has the issue while Keras does not.
Have I made some glaring error somewhere?
Any help would be greatly appreciated.
*It still generates varying outputs that at least slightly resemble the expected output moire often than not. This differs from my flawed PyTorch implementation, which produces a singular constant output with less semblance to the expected output than anything the Keras model yields.