def dense_layer(inp, n_neurons):
# input to a fully connected layer -> 2D [batch_size, n_inputs]
n_inputs = int(inp.shape[1])
W = tf.Variable(tf.truncated_normal((n_inputs,n_neurons), stddev=0.1))
b = tf.Variable(tf.random_normal(shape=[n_neurons]))
# or if you prefer
# b = tf.Variable(tf.zeros([n_neurons]))
x = tf.matmul(inp,W) + b
x = tf.nn.relu(x)
return x
pretrained_word_embedding_TF_nn.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录