Skip to content

Instantly share code, notes, and snippets.

@apoorvnandan
Last active August 29, 2019 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apoorvnandan/cfc35576c46a819c3ca69be73bccd237 to your computer and use it in GitHub Desktop.
Save apoorvnandan/cfc35576c46a819c3ca69be73bccd237 to your computer and use it in GitHub Desktop.
class ASR(tf.keras.Model):
def __init__(self, filters, kernel_size, conv_stride, conv_border, n_lstm_units, n_dense_units):
super(ASR, self).__init__()
self.conv_layer = tf.keras.layers.Conv1D(filters,
kernel_size,
strides=conv_stride,
padding=conv_border,
activation='relu')
self.lstm_layer = tf.keras.layers.LSTM(n_lstm_units,
return_sequences=True,
activation='tanh')
self.lstm_layer_back = tf.keras.layers.LSTM(n_lstm_units,
return_sequences=True,
go_backwards=True,
activation='tanh')
self.blstm_layer = tf.keras.layers.Bidirectional(self.lstm_layer, backward_layer=self.lstm_layer_back)
self.dense_layer = tf.keras.layers.Dense(n_dense_units)
def call(self, x):
x = self.conv_layer(x)
x = self.blstm_layer(x)
x = self.dense_layer(x)
return x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment