def RNN_forward_prop(X, Y, a0, parameters, vocab_size): x = {} a = {} y_hat = {} a[-1] = np.copy(a0) loss= 0 # Iterate for the T timesteps for t in range(len(X)): # One-hot representation of the t-th character x[t] = np.zeros((vocab_size, 1)) if X[t] != None: x[t][X[t]] = 1 # Run one timestep of forward prop a[t], y_hat[t] = RNN_forward_prop_step(parameters, a[t-1], x[t]) # Update loss function loss -= np.log(y_hat[t][Y[t],0]) cache = (y_hat, a, x) return loss, cache