Skip to content

Commit 8364819

Browse files
committed
deprecate convolution.py; rename to convolutional1
1 parent c73e211 commit 8364819

3 files changed

Lines changed: 25 additions & 22 deletions

File tree

configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
gui_spectrogram_clip=[1,99]
7171

7272
# neural network architecture to use
73-
architecture_plugin="convolutional2"
73+
architecture_plugin="convolutional"
7474
overlapped_prefix="not_"
7575

7676
# on what computer to do the computation

src/convolutional.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@ def model_parameters(time_units, freq_units, time_scale, freq_scale):
190190
["kernel_sizes", "kernels", '', '5x5,3', 1, [], None, True],
191191
["nfeatures", "# features", '', '64,64', 1, [], None, True],
192192
["dropout_kind", "dropout kind", ['none',
193-
'unit',
194-
'map'], 'unit', 1, [], None, True],
193+
'unit'], 'unit', 1, [], None, True],
195194
["dropout_rate", "dropout %", '', '50', 1, ["dropout_kind",
196195
["unit",
197196
"map"]], None, True],
@@ -392,8 +391,6 @@ def create_model(model_settings, model_parameters, io=sys.stdout):
392391
dropout_rate = float(model_parameters['dropout_rate'])/100
393392
if model_parameters['dropout_kind']=='unit':
394393
dropout_kind = Dropout
395-
elif model_parameters['dropout_kind']=='map':
396-
dropout_kind = SpatialDropout2D
397394
else:
398395
def Identity(x): return lambda x: x
399396
dropout_kind = Identity
@@ -500,10 +497,9 @@ def Identity(x): return lambda x: x
500497
hidden_layers.append(conv)
501498
if normalize_before:
502499
conv = BatchNormalization()(conv)
503-
relu = ReLU()(conv)
500+
x = ReLU()(conv)
504501
if normalize_after:
505-
relu = BatchNormalization()(relu)
506-
x = dropout_kind(dropout_rate)(relu)
502+
x = BatchNormalization()(x)
507503
x_shape = x.get_shape().as_list()
508504
noutput_tics = math.ceil((noutput_tics - dilated_kernel_size[0] + 1) / strides[0])
509505
iconv += 1
@@ -531,10 +527,9 @@ def Identity(x): return lambda x: x
531527
hidden_layers.append(conv)
532528
if normalize_before:
533529
conv = BatchNormalization()(conv)
534-
relu = ReLU()(conv)
530+
x = ReLU()(conv)
535531
if normalize_after:
536-
relu = BatchNormalization()(relu)
537-
x = dropout_kind(dropout_rate)(relu)
532+
x = BatchNormalization()(x)
538533
x_shape = x.get_shape().as_list()
539534
noutput_tics = math.ceil((noutput_tics - dilated_kernel_size + 1) / strides[0])
540535
iconv += 1
@@ -548,6 +543,8 @@ def Identity(x): return lambda x: x
548543
print("receptive_field_freq = %d bins = %f %s" % (receptive_field[1],
549544
receptive_field[1] * audio_tic_rate / window_tics / freq_scale, freq_units), file=io)
550545

546+
x = dropout_kind(dropout_rate)(x)
547+
551548
if pool_kind:
552549
x = pool_kind(pool_size=pool_size, strides=pool_size)(x)
553550
x_shape = x.get_shape().as_list()
@@ -559,9 +556,10 @@ def Identity(x): return lambda x: x
559556
relu = ReLU()(x)
560557
x = dropout_kind(dropout_rate)(relu)
561558
x = Conv2D(nunits, (noutput_tics if idense==0 else 1, x_shape[2]))(x)
559+
hidden_layers.append(conv)
562560
x_shape = x.get_shape().as_list()
563561

564562
final = Reshape((-1,model_settings['nlabels']))(x)
565563

566-
print('convolutional.py version = 0.1', file=io)
564+
print('convolutional.py version = 0.1.1', file=io)
567565
return tf.keras.Model(inputs=inputs, outputs=[hidden_layers, final], name="convolutional")
Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# this was the version of the default convolutional plugin use in songexplorer <= v0.7
2+
# it differs and is incompatible from that in v0.8 in which layers in strides
3+
14
import sys
25
import math
36

@@ -190,7 +193,8 @@ def model_parameters(time_units, freq_units, time_scale, freq_scale):
190193
["kernel_sizes", "kernels", '', '5x5,3', 1, [], None, True],
191194
["nfeatures", "# features", '', '64,64', 1, [], None, True],
192195
["dropout_kind", "dropout kind", ['none',
193-
'unit'], 'unit', 1, [], None, True],
196+
'unit',
197+
'map'], 'unit', 1, [], None, True],
194198
["dropout_rate", "dropout %", '', '50', 1, ["dropout_kind",
195199
["unit",
196200
"map"]], None, True],
@@ -391,6 +395,8 @@ def create_model(model_settings, model_parameters, io=sys.stdout):
391395
dropout_rate = float(model_parameters['dropout_rate'])/100
392396
if model_parameters['dropout_kind']=='unit':
393397
dropout_kind = Dropout
398+
elif model_parameters['dropout_kind']=='map':
399+
dropout_kind = SpatialDropout2D
394400
else:
395401
def Identity(x): return lambda x: x
396402
dropout_kind = Identity
@@ -497,9 +503,10 @@ def Identity(x): return lambda x: x
497503
hidden_layers.append(conv)
498504
if normalize_before:
499505
conv = BatchNormalization()(conv)
500-
x = ReLU()(conv)
506+
relu = ReLU()(conv)
501507
if normalize_after:
502-
x = BatchNormalization()(x)
508+
relu = BatchNormalization()(relu)
509+
x = dropout_kind(dropout_rate)(relu)
503510
x_shape = x.get_shape().as_list()
504511
noutput_tics = math.ceil((noutput_tics - dilated_kernel_size[0] + 1) / strides[0])
505512
iconv += 1
@@ -527,9 +534,10 @@ def Identity(x): return lambda x: x
527534
hidden_layers.append(conv)
528535
if normalize_before:
529536
conv = BatchNormalization()(conv)
530-
x = ReLU()(conv)
537+
relu = ReLU()(conv)
531538
if normalize_after:
532-
x = BatchNormalization()(x)
539+
relu = BatchNormalization()(relu)
540+
x = dropout_kind(dropout_rate)(relu)
533541
x_shape = x.get_shape().as_list()
534542
noutput_tics = math.ceil((noutput_tics - dilated_kernel_size + 1) / strides[0])
535543
iconv += 1
@@ -543,8 +551,6 @@ def Identity(x): return lambda x: x
543551
print("receptive_field_freq = %d bins = %f %s" % (receptive_field[1],
544552
receptive_field[1] * audio_tic_rate / window_tics / freq_scale, freq_units), file=io)
545553

546-
x = dropout_kind(dropout_rate)(x)
547-
548554
if pool_kind:
549555
x = pool_kind(pool_size=pool_size, strides=pool_size)(x)
550556
x_shape = x.get_shape().as_list()
@@ -556,10 +562,9 @@ def Identity(x): return lambda x: x
556562
relu = ReLU()(x)
557563
x = dropout_kind(dropout_rate)(relu)
558564
x = Conv2D(nunits, (noutput_tics if idense==0 else 1, x_shape[2]))(x)
559-
hidden_layers.append(conv)
560565
x_shape = x.get_shape().as_list()
561566

562567
final = Reshape((-1,model_settings['nlabels']))(x)
563568

564-
print('convolutional2.py version = 0.1.1', file=io)
565-
return tf.keras.Model(inputs=inputs, outputs=[hidden_layers, final], name="convolutional2")
569+
print('convolutional1.py version = 0.1', file=io)
570+
return tf.keras.Model(inputs=inputs, outputs=[hidden_layers, final], name="convolutional1")

0 commit comments

Comments
 (0)