728x90
반응형
import tensorflow as tf
x = tf.constant([[1., 2.],
[3., 6.]])
🙌 기본 함수 개요
+,-,*,/ | 텐서간 사칙연산 가능 |
tf.transpose(x) | 행열전환 |
@ | 내적 |
tf.nn.softmax(x, axis=-1) | 소프트맥스 함수 적용 |
tf.reduce_sum(x) | 합계 계산 |
tf.reduce_mean(x) | 평균 계산 |
tf.reduce_max(x) | 최대값 계산 |
tf.convert_to_tensor() | tensor로 변환 |
tf.Varable() | 텐서와 달리 assign으로 값 할당, 덧셈 가능 var = tf.variable([1.,2.,3.]) var.assign([2,2,2]) #새로 값 할당하기 var.assign_add([1,1,1]) #기존 값들에 값 더하기 var.assign_sub([1,1,1]) #기존 값들에 값 더하기 |
tf.GradientTape() | 자동으로 미분을 계산해줌 with tf.GradientTape() as tape: y = f(x) tape.gradient(y, x) #자동미분된 f(x)에 x값을 대입한 결과값 반환 |
tf.reshape(x,[row,column]) | 기존 reshape과 동일하게 제시된 shape에 따라 차원 변화 |
tf.matmul(t1,t2) | 곱셈 수행 |
tf.strings.split(문자열 tensor,sep='') | 파이썬의 split과 동일 기능 수행 |
**string 형태의 텐서 shape 주의!
tf.constant(['a','b','c'])가 있다면 shape는 [3,] 입니다.
텐서에서 문자열의 길이는 차원과 관련이 없습니다.
Source:
https://www.tensorflow.org/guide/tensor?hl=en
https://www.tensorflow.org/guide/basics?hl=en
728x90
반응형
'Data Science > Deep Learning' 카테고리의 다른 글
GAN 모델 구현 사이트 추천 (0) | 2022.11.12 |
---|---|
Keras 모델 훈련 API 정리 (compile,fit) (0) | 2022.11.06 |
Keras 모델 fit 결과값 해석하기! (0) | 2022.11.06 |
Tensorflow axis = -1 의미 파악하기 (0) | 2022.11.04 |
NotImplementedError: Cannot convert a symbolic Tensor to a numpy array 해결 방법 (0) | 2022.10.30 |
댓글