Created
April 4, 2019 18:27
-
-
Save marcopeix/e67d8b95027cee35d9da3f2fc1e17487 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def djmodel(Tx, n_a, n_values): | |
# Define the input of your model with a shape | |
X = Input(shape=(Tx, n_values)) | |
# Define s0, initial hidden state for the decoder LSTM | |
a0 = Input(shape=(n_a,), name='a0') | |
c0 = Input(shape=(n_a,), name='c0') | |
a = a0 | |
c = c0 | |
# Step 1: Create empty list to append the outputs while you iterate | |
outputs = [] | |
# Step 2: Loop | |
for t in range(Tx): | |
# Step 2.A: select the "t"th time step vector from X. | |
x = Lambda(lambda x: X[:,t,:])(X) | |
# Step 2.B: Use reshapor to reshape x to be (1, n_values) | |
x = reshapor(x) | |
# Step 2.C: Perform one step of the LSTM_cell | |
a, _, c = LSTM_cell(x, initial_state=[a, c]) | |
# Step 2.D: Apply densor to the hidden state output of LSTM_Cell | |
out = densor(a) | |
# Step 2.E: add the output to "outputs" | |
outputs.append(out) | |
# Step 3: Create model instance | |
model = Model(inputs=[X, a0, c0], outputs=outputs) | |
return model |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment