728x90
반응형

딥러닝 44

[딥러닝] 딥러닝 활용하기(임의 흑백, 컬러 이미지 데이터 셋 학습)

임의 흑백 이미지 데이터 셋 생성하기 import tensorflow as tf import numpy as np X=np.random.randint(0,256,(60000,28,28)) YT=np.random.randint(0,10,(60000,)) x=np.random.randint(0,256,(10000,28,28)) yt=np.random.randint(0,10,(10000,)) print(X.shape, YT.shape, x.shape, yt.shape) import matplotlib.pyplot as plt plt.imshow(X[0]) plt.show() print(YT[0]) 임의 흑백 이미지 데이터 셋 학습하기 import tensorflow as tf import numpy as np..

[딥러닝] 딥러닝 활용하기(cifar100 데이터 셋 학습하기)

CIFAR-100 데이터 셋 차원 살펴보기 import tensorflow as tf mnist=tf.keras.datasets.cifar100 (X,YT),(x,yt)=mnist.load_data() print(X.shape, YT.shape, x.shape, yt.shape) import matplotlib.pyplot as plt plt.imshow(X[0]) plt.show() print(YT[0]) CIFAR-100 데이터 셋 학습하기 import tensorflow as tf mnist=tf.keras.datasets.cifar100 (X,YT),(x,yt)=mnist.load_data() X=X.reshape(50000,32*32*3)/255 x=x.reshape(10000,32*32*3)/..

[딥러닝] 딥러닝 활용하기(cifar10 데이터 셋 학습하기)

CIFAR-10 데이터 셋은 6만장, 10 종류의 32x32 컬러 이미지로 구성되며,각각의 종류는 6천장의 이미지로 되어 있습니다. 6만장의 이미지는 5만장의 훈련용 이미지와 1만장의 시험용 이미지로 구성됩니다. import tensorflow as tf mnist=tf.keras.datasets.cifar10 (X,YT),(x,yt)=mnist.load_data() print(X.shape, YT.shape, x.shape, yt.shape) import matplotlib.pyplot as plt plt.imshow(X[0]) plt.show() print(YT[0]) CIFAR-10 데이터 셋 학습하기 import tensorflow as tf mnist=tf.keras.datasets.cifar1..

[딥러닝] 딥러닝 활용하기(패션 MNIST 데이터 셋 학습하기)

패션 MNIST 데이터 셋은 10개의 범주 (category)와 70,000개의 흑백 이미지로 구성되어 있습니다. import tensorflow as tf mnist = tf.keras.datasets.fashion_mnist (X, YT), (x, yt) = mnist.load_data() #60000개의 학습데이터, 10000개의 검증데이터 X, x = X/255, x/255 # 60000x28x28, 10000x28x28 X, x = X.reshape((60000,784)), x.reshape((10000,784)) model = tf.keras.Sequential([ tf.keras.Input(shape=(784,)), tf.keras.layers.Dense(128, activation='rel..

[딥러닝] 딥러닝 활용하기(MNIST 선형회귀)

MNIST 선형 회귀 import tensorflow as tf mnist = tf.keras.datasets.mnist (X, YT), (x, yt) = mnist.load_data() #60000개의 학습데이터, 10000개의 검증데이터 X, x = X/255, x/255 # 60000x28x28, 10000x28x28 X, x = X.reshape((60000,784)), x.reshape((10000,784)) model = tf.keras.Sequential([ tf.keras.Input(shape=(784,)), tf.keras.layers.Dense(512, activation='relu'), tf.keras.layers.Dense(256, activation='relu'), # 은닉화 tf..

[딥러닝] 딥러닝 활용하기(손글씨 숫자 데이터 인식)

MNIST라고 하는 손글씨 숫자 데이터를 입력받아 학습시켜봅니다. import tensorflow as tf mnist=tf.keras.datasets.mnist (X,YT),(x,yt)=mnist.load_data() #60000개의 학습데이터, 10000개의 검증데이터 X,x=X/255, x/255 # 60000x28x28, 10000x28x28 X,x=X.reshape((60000,784)), x.reshape((10000,784)) model = tf.keras.Sequential([ tf.keras.Input(shape=(784)), tf.keras.layers.Dense(128,activation='relu'), tf.keras.layers.Dense(10,activation='softmax'..

[딥러닝] 딥러닝 목표값 변경, 은닉층 늘리기, 학습 후 모델 내보내기, 모델 불러와 예측하기

딥러닝 목표값 형식을 2진수에서 10진수로 변경 _7seg_data.py import numpy as np np.set_printoptions(precision=4, suppress=True) X=np.array([ [ 1, 1, 1, 1, 1, 1, 0 ], # 0 [ 0, 1, 1, 0, 0, 0, 0 ], # 1 [ 1, 1, 0, 1, 1, 0, 0 ], # 2 [ 1, 1, 1, 1, 0, 0, 1 ], # 3 [ 0, 1, 1, 0, 0, 1, 1 ], # 4 [ 1, 0, 1, 1, 0, 1, 1 ], # 5 [ 0, 0, 1, 1, 1, 1, 1 ], # 6 [ 1, 1, 1, 0, 0, 0, 0 ], # 7 [ 1, 1, 1, 1, 1, 1, 1 ], # 8 [ 1, 1, 1, 0, 0,..

[딥러닝] 딥러닝 출력층에 linear 함수 적용해보기

linear 함수는 출력단의 값을 그대로 내보내는 함수로 linear 함수를 적용하여 학습을 수행할 경우 선형회귀라고 합니다. import tensorflow as tf from _7seg_data import X, YT model=tf.keras.Sequential([ tf.keras.Input(shape=(7,)), tf.keras.layers.Dense(16, activation='relu'), tf.keras.layers.Dense(4, activation='linear') ]) model.compile(optimizer='adam',loss='mse') model.fit(X,YT,epochs=10000) Y=model.predict(X) print(Y)

[딥러닝] 딥러닝 국소해의 문제 해결해보기

인공신경망 학습이 제대로 되지 않는 경우 국소해 문제로 발생합니다. 국소해 문제가 발생할 경우엔 재학습을 수행해보거나 은닉층의 노드수를 변경해봅니다. import tensorflow as tf from _7seg_data import X, YT model=tf.keras.Sequential([ tf.keras.Input(shape=(7,)), tf.keras.layers.Dense(16, activation='relu'), tf.keras.layers.Dense(4, activation='sigmoid') ]) model.compile(optimizer='adam',loss='mse') model.fit(X,YT,epochs=10000) Y=model.predict(X) print(Y)

[딥러닝] 딥러닝 7 세그먼트 인공 신경망

텐서플로를 활용하여 7 세그먼트 숫자 값에 따라 표시되는 LED의 ON, OFF 값을 입력 받아 2진수로 출력하는 인공신경망을 구성하고 학습합니다. numpy 배열로 데이터 초기화하기 # _7seg_data.py import numpy as np np.set_printoptions(precision=4, suppress=True) X=np.array([ [ 1, 1, 1, 1, 1, 1, 0 ], # 0 [ 0, 1, 1, 0, 0, 0, 0 ], # 1 [ 1, 1, 0, 1, 1, 0, 0 ], # 2 [ 1, 1, 1, 1, 0, 0, 1 ], # 3 [ 0, 1, 1, 0, 0, 1, 1 ], # 4 [ 1, 0, 1, 1, 0, 1, 1 ], # 5 [ 0, 0, 1, 1, 1, 1, 1 ], ..

728x90
반응형