'Python' 카테고리의 글 목록 (6 Page) — 뚝딱이

Python

Python/이론, 기초

[Python] *args, **kwargs

*args *arguments의 줄임말로 함수 사용에 있어 parameter 이름은 사용자가 지정할 수 있다. 여러 개의 parameter를 함수에 넣고자 할 때 사용한다. tuple 형태로 제공된다. def num_add(*nums): sum = 0 for num in nums: sum += num return sum num_add(5,7,8) 20 **kwargs **keyword argument의 줄임말이다. 키워드를 제공한다. 딕셔너리 형태로 제공된다. def kwargs(**names): for key, value in names.items(): print("key : %s, value : %s "%(key,value)) if key == "김철수" : print("김철수 입니다.") retur..

Python/numpy & Pytorch

[Numpy] random 서브 모듈

https://codetorial.net/numpy/random.html Matplotlib와 함께 정리가 잘된 사이트 NumPy 난수 생성 (Random 모듈) - Codetorial 예제1 - 기본 사용 import numpy as np a = np.random.randn(5) print(a) b = np.random.randn(2, 3) print(b) sigma, mu = 1.5, 2.0 c = sigma * np.random.randn(5) + mu print(c) [ 0.06704336 -0.48813686 0.4275107 -0.9015714 -1.30597604] [[ 0.87354043 0.03783 codetorial.net Random 서브 모듈 Random 모듈에 있는 다양한 함수를..

Python/numpy & Pytorch

[Numpy] 데이터 생성

https://numpy.org/doc/stable/reference/routines.array-creation.html Array creation routines — NumPy v1.23 Manual Note numpy.rec is the preferred alias for numpy.core.records. numpy.org Numpy 과학 계산을 위한 연산 라이브러리 행렬 / 배열 처리를 위한 연산할 때 사용 사용 이유 Python의 list 보다 Numpy의 ndarray가 빠름 ndarray는 c언어로 구현, 연속된 메모리에 생성됨 전체 데이터를 한번에 계산함 (Vectorization) Python의 list 보다 적은 메모리를 사용함 선형 대수, 통계 관련 여러 함수를 내장하고 있음 Nump..

Python/구현

NO 내장 함수 2진수 곱셈 코드

보호되어 있는 글입니다.

Python/numpy & Pytorch

Pytorch Cuda CuDNN 설정하기

TORCH torch version = 1.10.0에서 GPU 설정하기 https://pytorch.org/ 난 pip로 깔았으나 conda를 사용하는 사람은 conda 누르고 깔면 됨. 아래를 terminal에 깔아준다. ' pip3 install torch==1.10.0+cu102 torchvision==0.11.1+cu102 torchaudio===0.10.0+cu102 -f https://download.pytorch.org/whl/cu102/torch_stable.html ' https://pytorch.org/get-started/previous-versions/ PyTorch An open source machine learning framework that accelerates the pa..

Python/이론, 기초

[Python] List

여러개의 값을 담을 수 있는 데이터 구조 (Mutable) List 생성 s = "hello world" a = list(s) #1 b = [2,5,"pyhon"] #2 c = s.split() #3 print(a , b , c , sep="\n") ['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'] [2, 5, 'pyhon'] ['hello', 'world'] 리스트 연산, Len, Del a = [1,2,3,4,5] b = [6,7,8,9,10] print(a+b) print(a*2) print(len(a)) del a[0] print(a) del a[2:] print(a) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [1, 2, 3, 4,..

Python/이론, 기초

[Python] 문자열 - Indexing, Slicing, Count, Find, Index, Join, Replace, Split

문자열 생성 (Immutable) print(' hello world ') print(" hello world ") print(''' hello world ''') print(""" hello world """) 이스케이프 코드 \' : 따옴표 문자 \" : 쌍따옴표 문자 \ : backslash 문자 \a : bell 문자 \b : backslash 문자 \f : Formfeed 문자 \n : newline 문 \r : carriage return 문자(\n와 동일하지 않다.) \t : tab 문자 \v : vertical tab 문자 문자열 연산 + 와 * 연산 가능 a = "hello " b = "world " print(a + b) print(a * 2) print(b * 5) print(a * ..

Python/이론, 기초

[Python] while

기본 구조 while 조건: 수행 문장1 수행 문장2 기본 사용법 조건이 참이면 문장을 수행함 count = 0 while count < 10: count += 1 print('count', count) count 1 count 2 count 3 count 4 count 5 count 6 count 7 count 8 count 9 count 10 도서 관리 프로그램을 만든다고 하면 num = 0 prompt = """ ... 1. 도서 추가 ... 2. 도서 삭제 ... 3. 도서 리스트 ... 4. 나가기 ... ... Enter number: """ while num != 4: print(prompt) num = int(input()) 위와 같은 코드를 넣어서 프로그램을 나가게 설정할 수 있다 whi..

파송송
'Python' 카테고리의 글 목록 (6 Page)