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+
14import sys
25import 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