Development Study/tensorflow
[tensorflow] 텐서플로우 - 텐서 만들기 #1
octo54
2021. 3. 10. 22:35
728x90
tf.constant()
- tf.constant() 함수로 텐서를 만들 수 있음
tf.constant(value, dtype=None, shape=None, name='Const')
이것저것 해보기
import tensorflow as tf
>>> tf.constant([1,2,3,])
<tf.Tensor: shape=(3,), dtype=int32, numpy=array([1, 2, 3], dtype=int32)>
- dtype 지정
>>> tf.constant([1,2,3],dtype=float)
<tf.Tensor: shape=(3,), dtype=float32, numpy=array([1., 2., 3.], dtype=float32)>
- shape 지정
- value의 shape 에 맞춰서 지정
>>> tf.constant([1,2,3],dtype=float,shape=(3,1))
<tf.Tensor: shape=(3, 1), dtype=float32, numpy=
array([[1.],
[2.],
[3.]], dtype=float32)>
728x90