목록머신러닝 (48)
안 쓰던 블로그

chkpoint_filepath = "best_model.h5" Mycallback = tf.keras.callbacks.ModelCheckpoint( filepath = chkpoint_filepath, monitor = "val_accuracy", #모델을 저장할 때 기준이 되는 값 save_weights_only = False, mode = "max", #for val_acc, this should be max save_best_only = True, save_freq = "epoch") 학습을 돌릴 때, 가장 결과가 좋았을 때의 모델을 저장하는 ModelCheckpoint를 많이 사용한다. 나도 항상 이것을 잘 사용을 해 왔다. 그런데 이번에 늘 쓰던 코드임에도 모델이 아예 생성되지 않는 에러가 ..
steps_per_epoch steps_per_epoch = 훈련 샘플 수 / 배치 사이즈 예시1: 총 45개의 훈련 샘플이 있고 배치사이즈가 3이면 최대 15 스텝으로 지정한다 (그 이하 가능) 예시2: 총 80개의 훈련 샘플이 있고 배치사이즈가 10이면 최대 8 스텝으로 지정한다 사이즈가 너무 크면 이런 에러가 뜬다 Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches (in this case, 150 batches). You may need to use the repeat() functio..

TensorFlow Developer Certificate Exam 1. Pycharm 프로젝트 하나 생성 파이썬 3.8로 설정한다 2. Settings-Project:프로젝트 이름-Python Interpreter- +클릭 필요 라이브러리 설치 2021.9.3 기준 버전은 다음과 같다 pip install numpy==1.19.5 터미널 창에서 이렇게 버전을 명시하여 설치해 주어도 된다 3. 버전 확인 import tensorflow_datasets as tfds import tensorflow as tf import keras as k import numpy as np import PIL as pil import pandas as pd import scipy as spy print('tensorflo..

Kaggle competiton 참가하면서 Cannot submit 에러를 많이 만났다 Your Notebook cannot use internet access in this competition 라는 에러가 뜨면서 제출이 되지 않는데, 해결은 간단한다 1. save할 때 Advanced Settings를 눌러서 "Save output for this version"으로 바꾼다 2. 캐글 노트북 우측 바에서 internet을 끈다 3. 다시 제출하면 해결

dropout을 적용한 forward propagation(순전파)을 계산할 때 주의할 점이 있다. 최종 cost가 dropout을 사용하지 않았을 때와 동일한 값을 유지하도록 마지막에 keep_prob값으로 나눠주는 것이다. 아래 순전파 코드가 있다. # GRADED FUNCTION: forward_propagation_with_dropout def forward_propagation_with_dropout(X, parameters, keep_prob = 0.5): """ Implements the forward propagation: LINEAR -> RELU + DROPOUT -> LINEAR -> RELU + DROPOUT -> LINEAR -> SIGMOID. Arguments: X -- inp..
케라스에서 커스텀 Attention(Layer)를 사용할 때 add_weight() got multiple values for argument 'name' 에러 1. class Attention(Layer) -> class Attention(keras.layers.Layer) 변경 2. add_weights 메소드 안에 Add shape=(...) 추가 두 가지로 해결 class Attention(tf.keras.layers.Layer): # 여기 def __init__(self, step_dim, ... def build(self, input_shape): assert len(input_shape) == 3 self.W = self.add_weight(shape=(input_shape[-1],), # ..

logistic regression back propagation derivative 로지스틱 회귀 역전파 미분 유도 로지스틱 회귀 역전파를 구하면 다음과 같다 $$da=-\frac{y}{a}+\frac{1-y}{1-a}$$ $$dz=a-y$$ $$dw=dz x$$ $$db=dz$$ $x$ 는 고정값이므로 $dx$ 를 구하지 않는다 검은색 식은 순전파 때의 식 1. $\frac{\partial L}{\partial a}$ 구하기 2. $\frac{\partial a}{\partial z}$ 구하기 3. $\frac{\partial L}{\partial z}$ 구하기