💻 개인공부 💻/텐서플로우, 케라스

💻 개인공부 💻/텐서플로우, 케라스

[Tensorflow/Keras] 자주 쓰는 tf 함수들을 정리해보자 (작성중)

tf.gather : 슬라이싱 인덱스에 따라 params 축에서 슬라이스를 수집하는 함수이다. a라는 배열에서 t라는 인덱스의 값만을 추출하고자 할 때 사용한다. a = np.array([1,2,3,4,5]) t = np.array([0,2,4]) result = tf.gather(a,t) print(result) # tf.Tensor([1 3 5], shape=(3,), dtype=int64)

💻 개인공부 💻/텐서플로우, 케라스

[Tensorflow / Keras] Tf.cast 함수

tf.cast함수에 대해 알아본다. tf.cast함수는 float형을 int형으로, 혹은 boolean형을 int형으로 캐스팅할 때 사용한다. 예시를 통해 알아가보자 float to int import tensorflow as tf import numpy as np float_n = np.random.random() print(float_n) int_n = tf.cast(float_n, tf.int64) print(int_n) boolean to int import tensorflow as tf import numpy as np bool_n = True print("bool_n is {}".format(bool_n)) int_n = tf.cast(bool_n, tf.int64) print("bool_n ..

공대생 배기웅
'💻 개인공부 💻/텐서플로우, 케라스' 카테고리의 글 목록