본문 바로가기
반응형
별찍기(직각삼각형) size = int(input("please input size")) for i in range(size): print("*"*i) size = int(input("please input size")) for i in range(size,0,-1): print("*"*i) 2020. 2. 8.
별찍기(정사각형) star_string = " * " size = int(input("please input size")) for i in range(size): print(star_string *size) 2020. 2. 8.
숫자야구 게임 import random print("야구게임을 시작합니다 !!!\n--------------------------") i = random.randint(1,9) j = random.randint(1,9) k = random.randint(1,9) result = [str(i),str(j),str(k)] # 야구게임 정답 print('답: ',result) # 확인용 지울거얌 answer = [] strike_count = 0 ball_count = 0 try_count = 0 while(strike_count 2020. 2. 8.
로또 번호 생성기 import random lotto = [] game = int(input("lotto 게임 수를 입력하세요:")) print("===============================") for m in range(1,game+1): for a in range(1,8): i = random.randrange(1,46) lotto.append(i) lotto = list(set(lotto)) bonus = random.randint(1,46) lotto.sort() #리스트 정렬 for overlap in range(0,3): if (len(lotto) != 7): last = random.randint(1, 46) lotto.append(last) print(lotto,'+',lotto.pop()) l.. 2020. 2. 8.
구구단 게임 import random import time import numpy as np import sys def check(x): #정답 체크 global correct_count if(x == int(result)): print("정답!! :",str(result)) correct_count = correct_count + 1 elif( int(x) != int(result)): print("오답!! :",str(result)) # correct_count = correct_count - 1 else: print("뭐야??") def question(a): #문제 생성하기 global result b = random.randint(2, 4) numbers = [random.randint(2, 12) for .. 2020. 2. 8.
CHAPTER 4 word2vec 속도 개선 3장에서의 word2vec 문제점 input layer의 one-hot 표현과 가중치 행렬 $W_{in}$의 곱 계산 어휘 수가 많아지면 one-hot vector의 size도 커짐(상당한 memory차지) hidden layer의 가중치 행렬 $W_{out} $의 곱 Softmax layer 계산 위 2개의 계산이 병목되며 많은 계산시간이 소요하는 문제 발생 #해결방법 -> Embedding Layer -> Negative Sampling(loss function) Embedding Layer 가중치 parameter로부터 '단어 ID에 해당하는 vector'를 추출하는 layer 기존 one-hot encoder와 matmul계층의 행렬 곱 계산(행렬의 특정 행 추출) 대신 사용 Embedding l.. 2020. 2. 6.
CHAPTER 3 word2vec 3.1 추론 기반 기법과 신경망 단어를 벡터로 표현하는 방법 통계 기반 기법 추론 기반 방법 3.1.1 통계 기반 기법의 문제점 통계 기반 기법 - 학습 데이터를 한번에 처리(배치 학습) 추론 기반 기법 - 학습 데이터의 일부를 사용하여 순차적으로 학습(미니배치 학습) 3.1.3 신경망에서의 단어 처리 신경망에서 단어를 사용하기 위해 고정 길이의 벡터로 변환 one-hot 벡터 - 벡터의 원소 중 하나만 1, 나머지는 모두 0인 벡테 3.2 단순한 word2vec CBOW(continuous bag-of-words) 모델의 추론 처리 CBOW - context(주변 단어)로부터 Target(중앙 단어)을 추측하는 용도의 신경망 다중 클래스 분류 신경망 맥락에 포함시킬 단어가 N개일 경우 입력층도 N개 완.. 2020. 2. 3.
CHAPTER2 - 자연어와 단어의 분산 표현 2.1 자연어 처리(NLP - Natural Language Processing) - 자연어(natural language) : 인간의 언어 - 자연어 처리 - '자연어를 처리하는 분야 - '인간의 말을 컴퓨터에게 인해시키기 위한 기술(분야)' 2.1.1 단어의 의미 - 단어 : 의미의 최소 단위 2.2 시소러스 - 유의어 사전 - 사람이 직접 단어의 의미를 정의하는 방식 - 뜻이 같은 단어(동의어)나 뜻이 비슷한 단어(유의어) 를 한 그룹으로 분류한 사전 ex) car = auto / automobile / machine / motorcar - 모든 단어에 대한 유의어 집합을 이용하여 단어들의 관계를 그래프로 표현 및 단어 사이의 연결 정의 가능 -> 단어 사이의 연관성 학습 가능 문제점 - 사람의 수.. 2020. 1. 31.
tensorflow 2.0 기초 분류 (가이드 기본 이미지 분류) # 파이썬 라이브러리 임포트 from __future__ import absolute_import, division, print_function, unicode_literals, unicode_literals import tensorflow as tf from tensorflow import keras import numpy as np import matplotlib.pyplot as plt # 패션 mnist 데이터 로드 fashion_mnist = keras.datasets.fashion_mnist (train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data() # 이미지 출력시 필요한 변수 저장 class_nam.. 2020. 1. 17.
tensorflow 2.0 mnist간단 모델(가이드 - 초보용) # 텐서플로 라이브러리 임포트 from __future__ import absolute_import, division, print_function, unicode_literals !pip install -q tensorflow-gpu==2.0.0-rc1 import tensorflow as tf # MNIST 데이터셋 로드, 샘플 값을 정수 -> 부동소수 mnist = tf.keras.datasets.mnist #mnist 로드 (x_train, y_train), (x_test, y_test) = mnist.load_data() x_train, x_test = x_train / 255.0, x_test / 255.0 #계산의 편의를 위해 실수로 # layer를 쌓아 모델 구축. optimizer, los.. 2020. 1. 17.
반응형