I a currently trying to perform a 1d convolution on a image using a 2d kernel. The 1d convolution should be performed across the X-axis of the image, the images are spectograms of audio files. The image in which the convolution in performed is divided in to 13 section, each section centers around a center frequency, in which 13 different CNN network will perform 1d convolution to extract in total (x,13) feature points, and individually (x,1) feature points. x is given by the length of `data_output_train`
The kernel size is defined as such the center element will be the center frequency.
This is how the data is currently stored:
def model(feature,train_input_data,
train_output_data,
test_input_data,
test_output_data):
#Feature number 0-12
number_of_filters = 1
#Debug stuff!
print feature
print center_freq[feature]
print center_freq[feature]*2
print int(center_freq[feature]*2)
print frequency_to_pixel_row(int(center_freq[feature]*2))
col = int(frequency_to_pixel_row(int(center_freq[feature]*2)))
#init Data containers
data_train_input = []
data_test_input = []
data_train_output = []
data_test_output = []
print "jghkjhk"
#Extract the desired section
for images in train_input_data:
if feature == 0:
#print images.shape[0]
data_train_input = images[images.shape[0] - int(center_freq[feature]*2):images.shape[0],:]
#print data.shape
#Vstack so it can be used in keras
data_train_input_vstack = np.vstack(data_train_input)
#Extract the desired section
for images in test_input_data:
if feature == 0:
#print images.shape[0]
data_test_input = images[images.shape[0] - int(center_freq[feature]*2):images.shape[0],:]
#print data.shape
data_test_input_vstack = np.vstack(data_test_input)
#Extract the desired output data
for rows in train_output_data:
#print rows.shape
data_train_output = rows[:,feature]
data_train_output_vstack = np.vstack(data_train_output)
#Extract the desired output data
for rows in test_output_data:
#print rows.shape
data_test_output = rows[:,feature]
data_test_output_vstack = np.vstack(data_test_output)
Now i need to define the network structure such that it performs the 1d convolution.. But how do i ensure it also does that? and performs the way i want it to do.. I guess i have to use convolution2d, but how do i fix it to only perform 1d convoulution?