def main(mode, conv_until=None): # setup stuff to build model # This is it. use melgram, up to 6000 (SR is assumed to be 12000, see model.py), # do decibel scaling assert mode in ('feature', 'tagger') if mode == 'feature': last_layer = False else: last_layer = True if conv_until is None: conv_until = 4 K.set_image_dim_ordering('th') assert K.image_dim_ordering() == 'th', ('image_dim_ordering should be "th". ' + 'open ~/.keras/keras.json to change it.') args = Namespace(tf_type='melgram', # which time-frequency to use normalize='no', decibel=True, fmin=0.0, fmax=6000, # mel-spectrogram params n_mels=96, trainable_fb=False, trainable_kernel=False, # mel-spectrogram params conv_until=conv_until) # how many conv layer to use? set it 4 if tagging. # set in [0, 1, 2, 3, 4] if feature extracting. model = my_models.build_convnet_model(args=args, last_layer=last_layer) model.load_weights('weights_layer{}_{}.hdf5'.format(conv_until, K._backend), by_name=True) model.layers[1].summary() model.summary() # and use it! return model
def main(mode): # setup stuff to build model # This is it. use melgram, up to 6000 (SR is assumed to be 12000, see model.py), # do decibel scaling assert mode in ('feature', 'tagger') if mode == 'feature': last_layer = False else: last_layer = True args = Namespace(test=False, data_percent=100, model_name='', tf_type='melgram', normalize='no', decibel=True, fmin=0.0, fmax=6000, n_mels=96, trainable_fb=False, trainable_kernel=False) model = models.build_convnet_model(args=args, last_layer=last_layer) model.load_weights('weights_{}.hdf5'.format(K._backend), by_name=True) model.layers[1].summary() model.summary()