0
$\begingroup$

Are these lines of code equivalent in Keras? From a few runs, they seem to be, and also intuitively since the channels dimension of my data is 1, my understanding is that a fully connected acts like a convolutional layer. Is one better computationally (they have the same number of parameters)?

Conv1D(filters=1, kernel_size=1, strides=1, padding='causal')
TimeDistributed(Dense(1))

For example, I have a regression problem, where I have (batches,64) points coming in and (batches,64) points coming out of the model.

My model is:

model = Sequential()
model.add(Reshape([64, 1], input_shape=(64,)))
model.add(BatchNormalization())
model.add(Conv1D(filters=4, kernel_size=8, strides=1, padding='causal', activation = 'relu'))
model.add(BatchNormalization())
model.add(Conv1D(filters=1, kernel_size=1, strides=1, padding='causal'))
model.add(Flatten())
model.compile(loss=loss, optimizer=optimizer)

My thinking for the layers is:
reshape dimensions to 3D. variance scale. conv layer, activation. variance scale. final layer: my question is whether is matters if its a TimeDistributed(Dense) or Conv in my situation. reshape back to a 2D waveform.

Thank you in advance!

$\endgroup$
0
$\begingroup$

First thing is that TimeDistributed should not be useful for your case. It helps when having 2D data consisted of timesteps (ex. in recurrent forms) and you only have one dimension : (64, 1).

Secondly to answer, yes, your intuition is right. Conv1D with size 1 and a channel size of 1 is equivalent to a Dense of size 1.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.