728x90
tf.gather
내가 원하는 방법으로 tensor 순서를 변경하기 위해 사용하기 용이함
tf.gather(
params, indices, validate_indices=None, axis=None, batch_dims=0, name=None
)
공식 문서가 이해가 안되서 GPT 예시 독촉한 1인
# 예시 스펙트럼(2차원 텐서)
spectra = tf.constant([
[10, 11, 12], # spectra[0]
[20, 21, 22], # spectra[1]
[30, 31, 32], # spectra[2]
[40, 41, 42], # spectra[3]
]) # shape=(4,3)
# 우리가 뒤섞고 싶은 순서를 인덱스로 적어 놓은 것
mix_indices = tf.constant([1, 2, 3, 0]) # shape=(4,)
tf.gather(spectra, mix_indices)
=> 결과
[
spectra[1], # [20, 21, 22]
spectra[2], # [30, 31, 32]
spectra[3], # [40, 41, 42]
spectra[0], # [10, 11, 12]
]
내가 섞고 싶은 대로 순서를 섞는 텐서를 만드는 함수인듯요ㅎㅎ
나머지 파라미터는 안써봤어요 공식 문서 가서 보셈요 >_<//
https://www.tensorflow.org/api_docs/python/tf/gather
tf.gather | TensorFlow v2.16.1
Gather slices from params axis axis according to indices. (deprecated arguments)
www.tensorflow.org
728x90
'michine learning(미친러닝) > ML 공부' 카테고리의 다른 글
| Varitional Auto-Encoder (VAE) - Encoder (1) | 2025.08.04 |
|---|---|
| tf.range, tf.equal, tf.where, tf.clip_by_value 정리 (0) | 2025.05.16 |
| (ML) 전이 학습 _ pre-trained, fine-tuning (0) | 2023.07.20 |
| (ML) 임베디드 ML 프레임워크 Tensor flow Lite,PyTorch Mobile (0) | 2023.07.19 |
| (ML) Yolo Fine_tuning 하는 법 (0) | 2023.07.17 |
댓글