x = Conv1D(filters=256,
kernel_size=(4),activation=LeakyReLU(),padding='causal',dilation_rate=2,bias_initializer=Constant(0.1),kernel_initializer=TruncatedNormal())(x)input_img = Input(shape=(500,128))(?,125,512)(?,500,1)--
You received this message because you are subscribed to the Google Groups "Keras-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keras-users+unsubscribe@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/keras-users/479e9b40-a23a-45a5-86a9-0ff6326dfe23%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
import numpy as np
from keras.layers import Input # define the input shape for the modelfrom keras.layers import Conv1D, MaxPooling1D, UpSampling1D # for the convnet structurefrom keras.models import Model # for the overall definition
from keras.initializers import Constant # bias initialisationfrom keras.initializers import TruncatedNormal # kernel initialissationfrom keras.layers.advanced_activations import LeakyReLU # activation function (from NSynth)
# define input shapeinput_img = Input(shape=(500,128))print('Some information about tensor expected shapes')print('Input tensor shape:', input_img.shape)
# define encoder convnet# obs: 1D convolution implementedx = Conv1D(filters=128,kernel_size=4,activation=LeakyReLU(),padding='causal',dilation_rate=4,bias_initializer=Constant(0.1),kernel_initializer=TruncatedNormal())(input_img)x = Conv1D(filters=256,kernel_size=(4),activation=LeakyReLU(),padding='causal',dilation_rate=2,bias_initializer=Constant(0.1),kernel_initializer=TruncatedNormal())(x)x = MaxPooling1D(pool_size=4,strides=4)(x)encoded = Conv1D(filters=512,kernel_size=4,activation=LeakyReLU(),padding='causal',bias_initializer=Constant(0.1),kernel_initializer=TruncatedNormal())(x)print('Encoded representation tensor shape:', encoded.shape)
# define decoder convnetx = Conv1D(filters=256,kernel_size=4,activation=LeakyReLU(),padding='causal',bias_initializer=Constant(0.1),kernel_initializer=TruncatedNormal())(encoded)x = UpSampling1D(size=4)(x)x = Conv1D(filters=128,kernel_size=4,activation=LeakyReLU(),padding='causal',dilation_rate=2,bias_initializer=Constant(0.1),kernel_initializer=TruncatedNormal())(x)decoded = Conv1D(filters=1,kernel_size=4,activation=LeakyReLU(),padding='causal',dilation_rate=4,bias_initializer=Constant(0.1),kernel_initializer=TruncatedNormal())(x)print('Decoded representation tensor shape:', decoded.shape)
# define overal autoencoder modelcae = Model(inputs=input_img, outputs=decoded)cae.compile(optimizer='adam', loss='mse')
# check for equal size# obs: the missing value is the batch_sizeif input_img.shape[1:] != decoded.shape[1:]: print('alert: in/out dimension mismatch')
alert: in/out dimension mismatchIt is impossible to know what went wrong without the full code, not just one layer.
On 25 April 2017 at 17:43, <mattia....@gmail.com> wrote:
I've been writing some script where I'm trying to reconstruct an input spectrogram using a convolutional autoencoder.I'm trying to interpret the spectrogram both as a raw image and as a temporal sequence. For the latter, I'm using Conv1D.An example of a layer in the structure isx = Conv1D(filters=256,
kernel_size=(4),activation=LeakyReLU(),padding='causal',dilation_rate=2,bias_initializer=Constant(0.1),kernel_initializer=TruncatedNormal())(x)Given an input:where in the spectrogram stft_frames=500 and mel_bins=128, I get an encoding representation of shape after some poolinginput_img = Input(shape=(500,128))and that's good. But when reconstructing, the decoding representation has shape(?,125,512)that is, seems that I lost my dimension.(?,500,1)Does it make sense? Or am I forced to use Conv2d?Thanks for helping.
--
You received this message because you are subscribed to the Google Groups "Keras-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keras-users...@googlegroups.com.