def conv1d_layer(inp, filter_shape):
"""This is a 1d conv, so filter_shape = [dim, input_channels, out_channels]"""
W = tf.Variable(tf.truncated_normal(filter_shape, stddev=0.01))
b = tf.Variable(tf.random_normal(shape=[filter_shape[2]]))
# or you could initialize it as constant
# b = tf.Variable(tf.constant(0.1, shape=[filter_shape[3]]))
x = tf.nn.conv1d(inp,W,stride=1,padding="VALID")
x = tf.nn.bias_add(x, b)
x = tf.nn.relu(x)
return x
pretrained_word_embedding_TF_nn.py 文件源码
python
阅读 31
收藏 0
点赞 0
评论 0
评论列表
文章目录