Feature Column Pre-trained Embedding

前端 未结 2 648
渐次进展
渐次进展 2021-01-24 14:46

How to use pre-trained embedding with tf.feature_column.embedding_column.

I used pre_trained embedding in tf.feature_column.embedding_co

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-24 15:34

    You can also wrap your array into a function like this:

    some_matrix = np.array([[0,1,2],[0,2,3],[5,6,7]])
    
    def custom_init(shape, dtype):
        return some_matrix
    
    embedding_feature = tf.feature_column.embedding_column(itemx_vocab, 
                                                           dimension=3, 
                                                           initializer=custom_init
                                                           )
    
    

    It's an hacky way but does the job.

提交回复
热议问题