【发布时间】:2018-01-04 02:49:40
【问题描述】:
我想从具有相同形状的本地 numpy 数组初始化词嵌入层,这是来自另一个模型的预训练嵌入。 如果我没有添加分区参数也没关系。 def word_embedding(shape, dtype=tf.float32, name='word_embedding'):
f = open('./cnn_embed_array', 'r')
embedding_array = pickle.load(f)
f.close()
print 'embedding_array loaded......'
with tf.device('/cpu:0'), tf.variable_scope(name):
return tf.get_variable('embedding', shape, dtype=dtype, initializer=tf.constant_initializer(embedding_array), trainable = False)
但是如果我在 tf.get_variable 函数中添加partitioner=tf.fixed_size_partitioner(20),它会给我一个错误,说参数是多余的。
partitionerparam 倾向于加快训练速度。我可以通过其他方式添加参数吗?
【问题讨论】:
标签: tensorflow