본문 바로가기

전체 글261

딥러닝 Transfer Learning 이란 (코드없음 진행순서만) 딥러닝 모델의 정확도를 높이기 위해선 대학원 이상의 전문지식을 요한다. 따라서 응용프로그래머는 잘 만들어진 검증된 모델을 가져다 쓴다는 개념이 Transfer Learning 이라고 한다. 사용법은 사이드바 딥러닝 부분에 자세히 설명해놓았기 때문에, 여기선 전체적인 그림만 그린다 1. 필요한 라이브러리를 임포트 2.Building the model (Loading the pre-trained model) 학습이 잘 된 모델의 베이스 모델만 가져온다.(헤드모델은 빼고) 3. Freezing the base model 가져온 베이스 모델 부분은 이미 특징을 잘잡게 학습되어있기 때문에 재학습 하지않도록 사전작업을 하는것 4.Defining the custom head for our network 내 문제에 맞.. 2023. 1. 2.
Pandas Prophet 라이브러리를 이용한 Time Series 데이터 예측 방법 AVOCADO 가격 예측 (Facebook Prophet )¶ STEP #0: 데이터셋¶ 데이터는 미국의 아보카도 리테일 데이터 입니다. (2018년도 weekly 데이터) 아보카도 거래량과 가격이 나와 있습니다. 컬럼 설명 : Date - The date of the observation AveragePrice - the average price of a single avocado type - conventional or organic year - the year Region - the city or region of the observation Total Volume - Total number of avocados sold 4046 - Total number of avocados with PLU 40.. 2023. 1. 2.
딥러닝 텐서플로우 에포크 시마다, 가장 좋은 모델을 저장하는, ModelCheckpoint 사용방법, 에포크 시마다, 기록을 남길 수 있는, CSVLogger 사용 방법 The Vehicle Type Classification Project¶ Summary¶ Use Case: Vehicle Type Algorithm: MobileNetV2 Number of training images: 603 Number of classes: 7 Batch Size: 64 Optimizer: Adam Learning Rate: 0.0001 Loss Type:CategoricalCrossentropy Transfer Learning: Yes | Imagenet Labels¶0: 'car-bus-alltypes', 1: 'car-sedan-alltypes', 2: 'car-suv-alltypes', 3: 'motocycle-bicycle-kids', 4: 'motocycle-bicycle-.. 2023. 1. 2.
딥러닝 텐서플로우 Transfer_Learning_and_Fine_Tunning 개와 고양이 분류를, 이미 잘 만들어진 뉴럴네트워크를 활용하여, 성능을 올려보자.¶ Stage 1: Install dependencies and setting up GPU environment¶ In [ ]: # !pip install tensorflow-gpu==2.0.0.alpha0 In [ ]: # !pip install tqdm Requirement already satisfied: tqdm in /usr/local/lib/python3.6/dist-packages (4.28.1) Downloading the Dogs vs Cats dataset¶ In [1]: !wget --no-check-certificate \ https://storage.googleapis.com/mledu-datasets.. 2023. 1. 2.
딥러니 텐서플로우 CNN을 이용하여, CIFAR-10 이미지 분류하기, 데이트셋이 이미 넘파이라면? CNN을 이용하여, CIFAR-10 이미지 분류하기¶ STEP 0: 데이터셋 설명¶ CIFAR-10 is a dataset that consists of several images divided into the following 10 classes: Airplanes Cars Birds Cats Deer Dogs Frogs Horses Ships Trucks The dataset stands for the Canadian Institute For Advanced Research (CIFAR) CIFAR-10 is widely used for machine learning and computer vision applications. The dataset consists of 60,000 32x32 colo.. 2023. 1. 2.
파이썬 원본 폴더에 이미지 파일 여러개를 일정비율로 나눠서, 랜덤으로 파일의 순서를 바꾼다음, 새로운폴더를 생성하여 넣는 방법 환경 : 리눅스 ( 윈도우도 됨) PetImages 라는 원본폴더 안에 Cat 폴더 안에는 고양이 사진이 12500장 Dog 폴더 안에는 개사진이 12500장 있다고 해보자 새로운 cats-v-dogs 라는 폴더를 생성하고 그안에 testing 폴더, training 폴더를 생성 testing 안에 cats, dogs training 안에 cats, dogs 폴더를 생성한다음 원본에 있는 사진을 일정 비율로 나눠서 (예를들면 9대1로 나누면 11250장, 1250장) testing 안에 cats 폴더에 1250장 testing 안에 dogs 폴더에 1250장 training 안에 cats 폴더에 11250장 training 안에 dogs 폴더에 11250장 이렇게 옮길것이다. 1.필요한 라이브러리를 임포.. 2022. 12. 30.
딥러닝 텐서플로우 이미지 증강 예시 Image Augmentation¶ Cats v Dogs 로 다음처럼 모델링 하고, 학습시켜본다. 4 convolutional layers with 32, 64, 128 and 128 convolutions train for 100 epochs 데이터 제너레이터를 통해 이미지를 증강한다.¶ train_datagen = ImageDataGenerator( rotation_range=40, width_shift_range=0.2, height_shift_range=0.2, shear_range=0.2, zoom_range=0.2, horizontal_flip=True, fill_mode='nearest') rotation_range is a value in degrees (0–180), a range wit.. 2022. 12. 30.
딥러닝 텐서플로우 개와 고양이 분류하는 Neural Network 만들기 Using more sophisticated images with Convolutional Neural Networks¶I실생활의 이미지는 모양도 다르고, 비율도 다르고, 색깔도 다양하다. 이러한 것들을 분류하는 CNN을 만들어 본다. Cats and Dogs 이미지 이용 개와 고양이 분류하는 Neural Network 만들기 Evaluate the Training and Validation accuracy Explore the Example Data¶ /tmp 컬럼에, 2000개의 이미지를 다운로드 받아서 저장한다. NOTE: 2,000 개의 이미지는 캐글에서 가져왔다. "Dogs vs. Cats" dataset 원래는 25,000 개의 이미지 이지만, 실습용으로 추렸음. In [ ]: In [2]: .. 2022. 12. 30.
딥러닝 텐서플로우 CNN 구조, pooling, 파이썬으로 압축파일 풀기, JPG나PNG 같은 이미지파일을 학습 데이터로 만드는 방법, 파이썬 각 폴더에 저장되어 있는 사진파일이름들 출력 1. CNN구조 결론부터 말하면 : 사진의 특징을 잡아서 압축하는 개념 이미지는 행과 열로 이루어져있다 예시 (28, 28) 그래서 Gray(1차원) 이미지 같은경우는 Flatton()만 사용해서 학습을 시키면 되지만. 컬러이미지는 R, G ,B 3장으로 이루어진것과 같다.(3차원 이라는것) (28, 28, 3) 그렇기에 변환 과정을 거쳐야 한다. 과정은 kernel 로 image에 stride 만큼 feature map으로 만들어 (Convolution + ReLu) (변환) MAX or Average 로 stride만큼 Pooling (Downsampling) 해서 Flattening 하는것 (압축) 2. 파이썬으로 압축파일 푸는방법 import zipfile file = zipfile.ZipFile.. 2022. 12. 30.
딥러닝 텐서플로우 CNN 인간,말 분류, 파이썬으로 압축풀기, 이미지파일을 넘파이 어레이로가져오기 이미지 파일 다운로드. 말, 인간 분류하기 위한 사진 파일 다운로드 하기 In [1]: !wget --no-check-certificate \ # !wget 리눅스 주피터노트북에서 웹파일을 가져오는 명령어 https://storage.googleapis.com/laurencemoroney-blog.appspot.com/horse-or-human.zip \ -O /tmp/horse-or-human.zip # -O 여기에 다운로드 받아라. --2022-12-30 02:05:48-- https://storage.googleapis.com/laurencemoroney-blog.appspot.com/horse-or-human.zip Resolving storage.googleapis.com (storage.goo.. 2022. 12. 30.
딥러닝 텐서플로우 CNN의 기본개념 kenel == filter == feature detector 라고도 함 https://poloclub.github.io/cnn-explainer/ 풀링 stride = 2 == (2행2열) 풀링이란 예를들어 4*4 를 2*2로 줄이는방법 relu == 0밑은 무조건 0으로 바꿈, 양수는 그대로 쓴다 Fully Connected == ANN (같은말) 이렇게 하는 이유는 1.컴퓨팅 자원을 적게 쓰기 위함 2.특징을 살린다(예를들면 위치정보 같은것) 2022. 12. 29.
딥러닝 텐서플로우 레이블링된 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.