Changing the scale of a tensor in tensorflow

后端 未结 3 731
轻奢々
轻奢々 2021-02-19 03:43

Sorry if I messed up the title, I didn\'t know how to phrase this. Anyways, I have a tensor of a set of values, but I want to make sure that every element in the tensor has a ra

3条回答
  •  忘了有多久
    2021-02-19 04:35

    According to the feature scaling in Wikipedia you can also try the Scaling to unit length:

    It can be implemented using this segment of code:

    In [3]: a = tf.constant([2.0, 4.0, 6.0, 1.0, 0])                                                                                                                                                                     
    In [4]: b = a / tf.norm(a)
    In [5]: b.eval()
    Out[5]: array([ 0.26490647,  0.52981293,  0.79471946,  0.13245323,  0.        ], dtype=float32)
    

提交回复
热议问题