From 3fd9b09b79b46ceb9442bc6179f33fc070091752 Mon Sep 17 00:00:00 2001 From: Alex Reichenbach Date: Thu, 14 Dec 2017 08:02:33 -0500 Subject: [PATCH] Fixing bug in Conv1d Finally pushing patch. I haven't run it, so make sure that it works before merging. I bring it up again, as the dead issue thread was brought back to life - #79 . --- src/layers/convolutional/Conv1D.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/layers/convolutional/Conv1D.js b/src/layers/convolutional/Conv1D.js index 8effbf8a..2c6036ec 100644 --- a/src/layers/convolutional/Conv1D.js +++ b/src/layers/convolutional/Conv1D.js @@ -36,6 +36,18 @@ export default class Conv1D extends Layer { this.description += dilation_rate > 1 ? `, dilation rate ${dilation_rate}` : '' this.description += activation !== 'linear' ? `, ${activation} activation` : '' + // Checks to convert tuples into scalars + if (Array.isArray(strides)) { + this.strides = strides[0] + } + if (Array.isArray(dilation_rate)) { + this.dilation_rate = dilation_rate[0] + } + + if (Array.isArray(kernel_size)) { + this.kernel_size = kernel_size[0] + } + if (padding !== 'valid' && padding !== 'same') { this.throwError('Invalid padding.') } @@ -55,13 +67,15 @@ export default class Conv1D extends Layer { // Conv1D is actually a shim on top of Conv2D, where // all of the computational action is performed // Note that we use `channels_first` dim ordering here. + // Note dilation_rate_temp is necessary due to strange this call. + var dilation_rate_temp = this.dilation_rate; const conv2dAttrs = { filters, - kernel_size: [kernel_size, 1], - strides: [strides, 1], + kernel_size: [this.kernel_size, 1], + strides: [this.strides, 1], padding, data_format: 'channels_first', - dilation_rate, + dilation_rate_temp, activation, use_bias }