목록TensorFlow (2)
뮤트 개발일지
TF2 API 개요 TensorFlow2에서 딥러닝 모델을 작성하는 방법 3가지: Sequential, Functional, Model Subclassing TensorFlow2 API로 모델 작성하기 Sequential API import tensorflow as tf from tensorflow import keras import numpy as np # 데이터 구성부분 mnist = keras.datasets.mnist (x_train, y_train), (x_test, y_test) = mnist.load_data() x_train, x_test = x_train / 255.0, x_test / 255.0 x_train=x_train[...,np.newaxis] x_test=x_test[...,n..
모델에 학습시킬 이미지 사이즈가 서로 다르면 서로 사이즈를 맞춰서 모델 학습을 시켜야 한다. IMG_SIZE = 160 # 리사이징할 이미지의 크기 def format_example(image, label): image = tf.cast(image, tf.float32) # image=float(image)같은 타입캐스팅의 텐서플로우 버전입니다. image = (image/127.5) - 1 # 픽셀값의 scale 수정 image = tf.image.resize(image, (IMG_SIZE, IMG_SIZE)) return image, label Flatten: 다차원을 1차원으로 축소 import numpy as np image = np.array([[1, 2], [3, 4]]) print(image..