TensorFlow의 주요 연산 함수
TensorFlow는 다양한 수학 연산 및 텐서 조작 함수를 제공한다.
다음은 자주 사용되는 주요 연산 함수 목록이다.
- tf.constant() : 상수텐서생성
기본 수학 연산:
- tf.add(x, y): 덧셈
- tf.subtract(x, y): 뺄셈
- tf.multiply(x, y): 요소별 곱셈
- tf.divide(x, y): 나눗셈
- tf.matmul(x, y): 행렬 곱셈
- tf.pow(x, y): 거듭제곱
- tf.exp(x): 지수 함수
- tf.sqrt(x): 제곱근
행렬 연산:
- tf.transpose(x): 전치
- tf.linalg.inv(x): 역행렬
- tf.linalg.det(x): 행렬식
- tf.linalg.solve(A, b): 선형 방정식 Ax = b 해
- tf.tensordot(a, b, axes): 텐서 축약
집계 연산:
- tf.reduce_sum(x, axis): 합계
- tf.reduce_mean(x, axis): 평균
- tf.reduce_max(x, axis): 최댓값
- tf.reduce_min(x, axis): 최솟값
- tf.argmax(x, axis): 최댓값 인덱스
- tf.argmin(x, axis): 최솟값 인덱스
활성화 함수:
- tf.nn.relu(x): ReLU
- tf.nn.sigmoid(x): Sigmoid
- tf.nn.tanh(x): tanh
- tf.nn.softmax(x): Softmax
기타 연산:
- tf.reshape(x, shape): 형태 변경
- tf.concat([x, y], axis): 연결
- tf.stack([x, y], axis): 스택
- tf.gather(x, indices): 인덱스에 따른 요소 추출
- tf.one_hot(indices, depth): 원-핫 인코딩
- tf.cast(x, dtype): 데이터 타입 변환
- tf.clip_by_value(x, min, max): 값 범위 제한
tf.math 모듈
삼각 함수:
- tf.math.sin(x): 사인 함수
- tf.math.cos(x): 코사인 함수
- tf.math.tan(x): 탄젠트 함수
- tf.math.asin(x): 아크사인 함수
- tf.math.acos(x): 아크코사인 함수
- tf.math.atan(x): 아크탄젠트 함수
- tf.math.sqrt(x) : 제곱근