본문 바로가기

수업(국비지원)/Python86

[Python] 컬러 이미지 분석하기 📌 ######################################### # 컬러 이미지 분석하기 # 인터넷을 통해 이미지 조회하기 image_path = tf.keras.utils.get_file('cat.jsp', '') image_path image = plt.imread(image_path) # 고양이 이미지의 배열값 image.shape # (241, 320, 3) import cv2 cv2.imshow("cat", image) plt.imshow(image) brg = cv2.split(image) # 색상별로 분리 bgr = cv2.split(image) bgr[0].shape # 빨강 bgr[1].shape # 초록 bgr[2].shape # 파랑 plt.imshow(bgr[0]) c.. 2023. 4. 27.
[Python] 이항 분류 📌 ########################################## # 이항 분류 : 분류의 종류가 2종류인 경우 import pandas as pd url = "" red = pd.read_csv(url + 'winequality-red.csv', sep=';') # red와인 정보 white = pd.read_csv(url + 'winequality-white.csv', sep=';') #white와인 정보 red.info() white.info() ''' 1 - fixed acidity : 주석산농도 2 - volatile acidity : 아세트산농도 3 - citric acid : 구연산농도 4 - residual sugar : 잔류당분농도 5 - chlorides : 염화나트륨농도.. 2023. 4. 27.
[Python] 2023-01-02 복습 📌 ################################################## # Fashion-MNIST 데이터셋 다운로드 from tensorflow.keras.datasets.fashion_mnist import load_data from tensorflow.keras.utils import to_categorical from sklearn.model_selection import train_test_split from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Flatten import numpy as np (x_train, y_train), (x_test, y_test) .. 2023. 4. 27.
[Python] Fashion-MNIST 데이터를 이용하여 예측 평가하기 📌 ################################################## # Fashion-MNIST 데이터셋 다운로드 from tensorflow.keras.datasets.fashion_mnist import load_data (x_train, y_train), (x_test, y_test) = load_data() print(x_train.shape,x_test.shape) #(60000, 28, 28) (10000, 28, 28) class_names=['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat', 'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot'] y_train[:10] # [9, 0.. 2023. 4. 27.
[Python] MNIST 데이터를 이용하여 숫자를 학습하여 숫자 인식 📌 # MNIST 데이터를 이용하여 숫자를 학습하여 숫자 인식하기. # MNIST 데이터셋 다운받기 from tensorflow.keras.datasets.mnist import load_data (x_train, y_train),(x_test, y_test)=\\ load_data(path='mnist.npz') x_train.shape # (60000, 28, 28), 훈련데이터 y_train.shape # (60000,) x_test.shape # (10000, 28, 28), 테스트데이터 y_test.shape # (10000,) import matplotlib.pyplot as plt import numpy as np # 0~59999 사이의 임의의 수 3개 random_idx = np.rand.. 2023. 4. 27.
[Python] Tensortflow ''' Tensorflow 설치 1. 연결 2. 다운로드 센터 클릭() 3.개발자 도구 클릭 4. 05. Visual Studio 2015용 vISUAL c++ 재배포 가능 선택 5. 다운로드 클릭 6. vc_redist.x64.exe 선택 => 다음클릭 => 다운받기 7. 파일탐색기에서 vc_redict.x64.exe 실행 8. anaconda prompt를 관리자 모드로 실행 9. pip install tensorflow 치기 tensorflow 버전 확인 : 2.11.0 ''' 📌 import tensorflow as tf # .__version__ : 버전 확인 가능 print(tf.__version__) # 2.11.0 # 현재 컴퓨터가 GPU? tf.config.list_physical_dev.. 2023. 4. 27.
[Python] 딥러닝 - 가중치와 편향, 다중 퍼센트론 📌 ''' 퍼셉트론을 이용하여 XOR 게이트 구현 단일 신경망으로 구현 안됨 다중 신경망으로 구현해야 한다. 단일 퍼센트론 : 입력층 - 출력층 다중 퍼센트론 : 입력층 - 은닉층 - 출력층 ''' def XOR(x1,x2) : s1 = NAND(x1,x2) s2 = OR(x1,x2) y = AND(s1,s2) return y for xs in [(0,0), (0,1), (1,0), (1,1)] : y = XOR(xs[0], xs[1]) print(xs,"=>",y) 2023. 4. 27.
[Python] 딥러닝 - 인공신경망(ANN) 📌 # 퍼셉트론 AND 게이트 구현 import numpy as np def AND(x1,x2) : x = np.array([x1,x2]) # 입력값 w = np.array([0.5, 0.5]) # 가중치 b = -0.8 # 편향 tmp = np.sum(w*x) + b if tmp 2023. 4. 27.