def forward(self, X, mode): h = np.zeros(self.hshape) # init hidden state for t in xrange(self.num_unroll_steps): h = layers.rnn_step(X, h, self.params['Wx'], self.params['Wh'], self.params['b']) y = layers.affine(h, self.params['Wa'], self.params['ba']) return y
def forward(self, X, mode): h = np.zeros(self.hshape) # init hidden state for t in range(self.num_unroll_steps): h = layers.rnn_step(X, h, self.params['Wx'], self.params['Wh'], self.params['b']) y = layers.affine(h, self.params['Wa'], self.params['ba']) return y
def forward(self, X, mode): seq_len = X.shape[1] h = self.params['h0'] for t in xrange(seq_len): h = layers.rnn_step(X[:, t, :], h, self.params['Wx'], self.params['Wh'], self.params['b']) y = layers.affine(h, self.params['Wa'], self.params['ba']) return y
def step(self, x, h, *args, **kwargs): """ Abstract step function for rnn :param x: current input, batched matrix :param h: previous output :return: output """ return layers.rnn_step(x, h, self.params('Wx'), self.params('Wh'), self.params('b'))
def forward(self, X, mode): seq_len = X.shape[1] batch_size = X.shape[0] hidden_size = self.params['Wh'].shape[0] h = np.zeros((batch_size, hidden_size)) for t in xrange(seq_len): h = layers.rnn_step(X[:, t, :], h, self.params['Wx'], self.params['Wh'], self.params['b']) y = layers.affine(h, self.params['Wa'], self.params['ba']) return y