3.1-AIND-VUI-speech-recognition-project/sample_models.py
def deep_rnn_model(input_dim, units, recur_layers, output_dim=29):
    """ Build a deep recurrent network for speech 
    """
    # Main acoustic input
    input_data = Input(name='the_input', shape=(None, input_dim))
    # TODO: Add recurrent layers, each with batch normalization
    simp_rnn = GRU(units, activation='relu',
            return_sequences=True, implementation=2, name='rnn1')(input_data)
    bn_rnn = BatchNormalization(name='bn_simp_rnn1')(simp_rnn)
    for ii in range(recur_layers-1):
        simp_rnn = GRU(units, activation='relu',
            return_sequences=True, implementation=2, name='rnn'+str(ii+2))(bn_rnn)
        bn_rnn = BatchNormalization(name='bn_simp_rnn'+str(ii+2))(simp_rnn)

    # TODO: Add a TimeDistributed(Dense(output_dim)) layer
    time_dense = TimeDistributed(Dense(output_dim)) (bn_rnn)
    # Add softmax activation layer
    y_pred = Activation('softmax', name='softmax')(time_dense)
    # Specify the model
    model = Model(inputs=input_data, outputs=y_pred)
    model.output_length = lambda x: x
    print(model.summary())
    return model
 Build a deep recurrent network for speech 
    
Build a deep recurrent network for speech
Build a deep recurrent network for speech
def deep_rnn_model(input_dim, units, recur_layers, output_dim=29):
    input_data = Input(name='the_input', shape=(None, input_dim))
    simp_rnn = GRU(units, activation='relu',
            return_sequences=True, implementation=2, name='rnn1')(input_data)
    bn_rnn = BatchNormalization(name='bn_simp_rnn1')(simp_rnn)
    for ii in range(recur_layers-1):
        simp_rnn = GRU(units, activation='relu',
            return_sequences=True, implementation=2, name='rnn'+str(ii+2))(bn_rnn)
        bn_rnn = BatchNormalization(name='bn_simp_rnn'+str(ii+2))(simp_rnn)
    time_dense = TimeDistributed(Dense(output_dim)) (bn_rnn)
    y_pred = Activation('softmax', name='softmax')(time_dense)
    model = Model(inputs=input_data, outputs=y_pred)
    model.output_length = lambda x: x
    print(model.summary())
    return model
def deep_rnn_model ( input_dim , units , recur_layers , output_dim = 29 ) : input_data = Input ( name = 'the_input' , shape = ( None , input_dim ) ) simp_rnn = GRU ( units , activation = 'relu' , return_sequences = True , implementation = 2 , name = 'rnn1' ) ( input_data ) bn_rnn = BatchNormalization ( name = 'bn_simp_rnn1' ) ( simp_rnn ) for ii in range ( recur_layers - 1 ) : simp_rnn = GRU ( units , activation = 'relu' , return_sequences = True , implementation = 2 , name = 'rnn' + str ( ii + 2 ) ) ( bn_rnn ) bn_rnn = BatchNormalization ( name = 'bn_simp_rnn' + str ( ii + 2 ) ) ( simp_rnn ) time_dense = TimeDistributed ( Dense ( output_dim ) ) ( bn_rnn ) y_pred = Activation ( 'softmax' , name = 'softmax' ) ( time_dense ) model = Model ( inputs = input_data , outputs = y_pred ) model . output_length = lambda x : x print ( model . summary ( ) ) return model
Build a deep recurrent network for speech
Build a deep recurrent network for speech
""" Build a deep recurrent network for speech 
    """ # Main acoustic input # TODO: Add recurrent layers, each with batch normalization # TODO: Add a TimeDistributed(Dense(output_dim)) layer # Add softmax activation layer # Specify the model
input_dim
units
recur_layers
output_dim