Python keras.layers.recurrent.time_distributed_dense() Examples

The following are code examples for showing how to use keras.layers.recurrent.time_distributed_dense(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: pointer-networks-experiments   Author: zygmuntz   File: PointerLSTM.py    BSD 2-Clause "Simplified" License 6 votes vote down vote up
def step(self, x_input, states):
    	#print "x_input:", x_input, x_input.shape
    	# <TensorType(float32, matrix)>
    	
        input_shape = self.input_spec[0].shape
        en_seq = states[-1]
        _, [h, c] = super(PointerLSTM, self).step(x_input, states[:-1])

        # vt*tanh(W1*e+W2*d)
        dec_seq = K.repeat(h, input_shape[1])
        Eij = time_distributed_dense(en_seq, self.W1, output_dim=1)
        Dij = time_distributed_dense(dec_seq, self.W2, output_dim=1)
        U = self.vt * tanh(Eij + Dij)
        U = K.squeeze(U, 2)

        # make probability tensor
        pointer = softmax(U)
        return pointer, [h, c] 
Example 2
Project: keras_bn_library   Author: bnsnapper   File: rnnrbm.py    MIT License 5 votes vote down vote up
def preprocess_input(self, x):
		if self.consume_less == 'cpu':
			input_shape = K.int_shape(x)
			input_dim = input_shape[2]
			timesteps = input_shape[1]
			return time_distributed_dense(x, self.W, self.b, self.dropout_W,
			                              input_dim, self.hidden_recurrent_dim,
			                              timesteps)
		else:
			return x 
Example 3
Project: research   Author: commaai   File: layers.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def preprocess_input(self, x):
      if self.consume_less == 'cpu':
          input_shape = self.input_spec[0].shape
          input_dim = input_shape[2]
          timesteps = input_shape[1]
          return time_distributed_dense(x, self.W, self.b, self.dropout_W,
                                        input_dim, self.output_dim,
                                        timesteps)
      else:
          return x 
Example 4
Project: research   Author: commaai   File: layers.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def preprocess_input(self, x):
      if self.consume_less == 'cpu':
          input_shape = self.input_spec[0].shape
          input_dim = input_shape[2]
          timesteps = input_shape[1]
          return time_distributed_dense(x, self.W, self.b, self.dropout_W,
                                        input_dim, self.output_dim,
                                        timesteps)
      else:
          return x 
Example 5
Project: conv-match   Author: ssamot   File: layers.py    GNU General Public License v2.0 5 votes vote down vote up
def preprocess_input(self, x):
        output_dim = 2
        if self.consume_less == 'cpu':
            input_shape = self.input_spec[0].shape
            input_dim = input_shape[2]
            timesteps = input_shape[1]
            return time_distributed_dense(x, self.W, self.b, self.dropout_W,
                                          input_dim, output_dim,
                                          timesteps)
        else:
            return x 
Example 6
Project: KerasCog   Author: ABAtanasov   File: Networks.py    MIT License 5 votes vote down vote up
def preprocess_input(self, x):
        if self.consume_less == 'cpu':
            input_shape = self.input_spec[0].shape
            input_dim = input_shape[2]
            timesteps = input_shape[1]
            return time_distributed_dense(x, self.W, self.b, self.dropout_W, 
                                          input_dim, self.output_dim, 
                                          timesteps)
        else:
            return x