딥러닝 텐서플로우 레이블링된 y값을 tf.keras.utils.to_categorical 함수 이용해서 원핫인코딩으로 바꾸기, 분류의 문제에서, loss 함수를 categorical_crossentropy로 설정할때는 어떤상황일때?
1.레이블링된 y값을 tf.keras.utils.to_categorical 함수 이용해서 원핫인코딩으로 바꾸기 from keras.utils import to_categorical y_train [out] array([5, 0, 4, ..., 5, 6, 8], dtype=uint8) y_train = tf.keras.utils.to_categorical(y_train, num_classes = 10) [out] array([[0., 0., 0., ..., 0., 0., 0.], [1., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.],..
2022. 12. 29.
딥러닝 텐서플로우 Flatten()을 사용하지않는, validation_data 파라미터 split 과의 차이, Dropout이란
1. Flatten() 라이브러리 없이 이미지 평탄화 하는방법 예시) X_train.shape # 3차원 (60000, 28, 28) X_train = X_train.reshape(60000, 784) # 평탄화 // 2차원 마찬가지로 X_test도 reshape을 이용한다 . 모델링 예시) def build_model() : model = Sequential() model.add( Dense(128, 'relu', input_shape=(784, ) ) ) model.add( Dropout(0.2) ) # 학습할때 20프로의 선을 없애라는뜻 (이부분만) model.add( Dense(64, 'relu')) model.add( Dense(10, 'softmax')) model.compile('adam',..
2022. 12. 29.