Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. def build_branch(self, name, W_emb, bias):
  2.     indices = tf.placeholder(tf.int64, shape=[None, 2], name=name + '__indices')
  3.     values = tf.placeholder(tf.float32, shape=[None], name=name + '__values')
  4.     dense_shape = tf.placeholder(tf.int64, shape=[2], name=name + '__dense_shape')
  5.  
  6.     sparse_input = tf.SparseTensor(indices, values, dense_shape)
  7.  
  8.     embedding = tf.nn.relu(tf.sparse_tensor_dense_matmul(sparse_input, W_emb) + bias)
  9.  
  10.     encoder = embedding
  11.     for layer in self.layers:
  12.         encoder = layer(encoder)
  13.  
  14.     return [indices, values, dense_shape], encoder
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement