728x90
반응형

딥러닝 44

[딥러닝] 사용자 데이터로 CNN 학습하기- 6. 시험 데이터로 확인해보기

6. 시험 데이터로 확인해보기 _04_cnn_training_5.py from _04_cnn_training_3 import * from tensorflow.keras.models import load_model import matplotlib.pyplot as plt model1=load_model('model.h5') # Model predictions for the testing dataset y_test_predict=model1.predict(x_test) print(y_test_predict.shape, y_test_predict[0]) y_test_predict=np.argmax(x_test_predict, axis=1) print(y_test_predict.shape, y_test_pred..

[딥러닝] 사용자 데이터로 CNN 학습하기- 5. 인공신경망 학습시키기

5. 인공신경망 학습시키기 _04_cnn_training_4.py from _04_cnn_training_3 import * import tensorflow as tf model=tf.keras.Sequential([ # donkey car CNN tf.keras.layers.Conv2D(24,(5,5), strides=(2,2), padding='same', activation='relu', input_shape=x_train.shape[1:]), tf.keras.layers.Dropout(0.2), tf.keras.layers.Conv2D(32,(5,5), strides=(2,2), padding='same', activation='relu'), tf.keras.layers.Dropout(0.2), ..

[딥러닝] 사용자 데이터로 CNN 학습하기- 4. 훈련, 검증, 시험 데이터 분리하기

4. 훈련, 검증, 시험 데이터 분리하기. 훈련 데이터 80%, 검증 데이터 10%, 시험 데이터 10%로 임의로 분리합니다. 훈련 데이터는 인공신경망 학습에 사용 검증 데이터는 학습 도중에 검증용으로 사용 시험 데이터는 학습이 끝난 후에 사용합니다. _04_cnn_training_3.py from _04_cnn_training_1 import * from tensorflow.keras.utils import to_categorical from sklearn.model_selection import train_test_split tensors=tensors.astype('float32')/255 targets=to_categorical(targets, 4) x_train, x_test, y_train, ..

[딥러닝] 사용자 데이터로 CNN 학습하기- 3. 수집한 이미지 출력해보기

3. 수집한 이미지 출력해보기 _04_cnn_training_2.py from _04_cnn_training_1 import * import cv2 import matplotlib.pyplot as plt # Name list names=['_0_forward','_1_right','_2_left','_3_stop'] def display_images(img_path, ax): img=cv2.imread(os.path.join(dirname,img_path)) ax.imshow(cv2.cvtColor(img,cv2.COLOR_BGR2RGB)) fig=plt.figure(figsize=(10,3)) for i in range(4): ax=fig.add_subplot(1,4,i+1,xticks=[], yti..

[딥러닝] 사용자 데이터로 CNN 학습하기- 2. 수집한 데이터 불러오기

2. 수집한 데이터 불러오기 수집한 데이터를 읽어와서 인공 신경망에서 사용할 수 있는 텐서로 변경합니다. 텐서는 3차원 이상의 행렬을 의미하며 프로그래밍 언어 관점에서는 3차원 이상의 배열이 됩니다. 04_cnn_training_1.py from tensorflow.keras.preprocessing import image as keras_image import os import numpy as np from tqdm import tqdm from PIL import ImageFile import pandas as pd dirname="data.1695035538.287210" def image_to_tensor(img_path): img=keras_image.load_img( os.path.join(d..

[딥러닝] 사용자 데이터로 CNN 학습하기- 1. 라벨링하기

1. 라벨링하기 수집한 이미지 데이터에 라벨링 작업을 합니다. _03_data_labelling.py import os import csv dataDir='data.1695035538.287210' # 데이터 저장 디렉토리 print(os.getcwd()) # 현재 디렉터리 어딘지 확인(cwd=current working directory) os.chdir(dataDir) # 디렉터리 이동(change directory) roadDirs=os.listdir() # 현재 디렉터리 확인 print(roadDirs) f_csv=open('0_road_labels.csv','w',newline='') wr=csv.writer(f_csv) wr.writerow(["file","label","labelNames"]..

[딥러닝] VGG16 바탕으로 신경망 구성하기, 배치 정규화, 드롭아웃 적용하기

참고 링크 [딥러닝 | CNN] - VGG16 (tistory.com) [딥러닝 | CNN] - VGG16 VGG16이 수록된 논문 "Very deep convolutional networks for large-scale image recognition" 의 Model Architecture 설명부분까지의 내용을 기반으로 정리하겠다. 1. VGG16란? ILSVRC 2014년 대회에서 2위를 한 CNN모델이다. 그중 brave-greenfrog.tistory.com 연습문제 1. VGG16 신경망 텐서플로로 구성하기 2. 임의 데이터 만드어서 신경망 테스트하기 import tensorflow as tf model=tf.keras.Sequential([ tf.keras.layers.InputLayer(in..

[딥러닝] 알렉스넷 바탕으로 신경망 구성하기, 배치 정규화, 드롭아웃 적용하기

알렉스넷 아키텍처 신경망 구성하기 import tensorflow as tf import numpy as np X=np.random.randint(0,256,(5000,227,227,3)) YT=np.random.randint(0,1000,(5000,)) x=np.random.randint(0,256,(1000,227,227,3)) yt=np.random.randint(0,1000,(1000,)) model = tf.keras.Sequential([ tf.keras.layers.InputLayer(input_shape=(227,227,3)), tf.keras.layers.Conv2D(96,(11,11),(4,4),activation='relu'), tf.keras.layers.MaxPooling2D((3..

[딥러닝] 딥러닝 모델 학습 후 저장하고 필터 이미지 추출하기

import tensorflow as tf mnist=tf.keras.datasets.cifar10 (x_train, y_train),(x_test, y_test)=mnist.load_data() x_train, x_test = x_train / 255.0, x_test / 255.0 # 모든 픽셀의 숫자를 255.0으로 나누어 각 픽셀을 실수로 바구어 인공신경망에 입력하게 됨 model = tf.keras.Sequential([ tf.keras.layers.InputLayer(input_shape=(32,32,3)), tf.keras.layers.Conv2D(24,(3,3),(1,1),activation='relu'), # 커널5*5 사이즈 -> stride 2,2 tf.keras.layers.Conv..

[딥러닝] CNN 활용 예제(엔비디아 자료 보고 신경망 구성하기)

참고 링크 End-to-End Deep Learning for Self-Driving Cars | NVIDIA Technical Blog End-to-End Deep Learning for Self-Driving Cars | NVIDIA Technical Blog We have used convolutional neural networks (CNNs) to map the raw pixels from a front-facing camera to the steering commands for a self-driving car. developer.nvidia.com 엔디비아 디벨롭 예제 1 import tensorflow as tf model = tf.keras.Sequential([ tf.keras.laye..

728x90
반응형