본문 바로가기

전체 글

(57)
Hyperparameter Tuning 모델, 데이터, H/T 중요도는 데이터 > 모델 > H/T 순 Hyperparameter Tuning learning rate, 모델의 크기, optimizer 등 grid, random, bayesian 기법 등 가성비가 떨어지니 마지막에 할 것 Ray multi node, multi processing ML/DL의 병렬 처리 표준 hyperparameter search를 위한 모듈 config에 search space 지정 학습 scheduling 알고리즘 지정 출력 양식 지정 tune.run() -> 병렬 처리
Model Control Model.save architecture, parameter 저장 model.state_dict() # 모델의 parameter 출력 torch.save(model.state_dict(),PATH) # 같은 형태의 모델의 parameter 저장 torch.load_state_dict(PATH) # 같은 형태의 모델에서 parameter 로드 torch.save(model, PATH) # architecture와 parameter 모두 저장 torch.load(PATH) # architecture와 parameter 모두 로드​ Checkpoints 학습의 중간 결과 저장, early stopping epoch, loss, mertric 값을 지속적으로 저장 torch.save({ 'epoch': e '..
Pytorch - Project template
Pytorch - basic Pytorch Define by Run - runtime 중 graph 생성 GPU support, good API, easy debugging 기본적으로 numpy의 사용법과 매우 유사 view, reshape은 contiguity(연속적인 데이터의 저장) 보장의 차이
Pandas Pandas Panel datas numpy와 통합하여 빠름 Series DataFrame loc, iloc, drop, reset_index, fill_value, lambda, map, apply, applymap, replace Built-in function describe, unique, sort_values, corr, cov, corrwith, pd.options.display Groupby split -> apply -> combine groupby, hierarchical index, unstack, reset_index, swaplevel, sort_index, sort_values, get_group, aggregation, transform, filter Pivot column에 l..
Numpy Numerical Python 일반 list에 비해 빠르고 효율적 python의 list는 mem address를 저장하지만, ndarray는 값을 직접 저장 list는 값의 변경이 용이하고 ndarray는 속도가 빠름 C++, 포트란 등과 통합 가능 import numpy as np 국룰 하나의 data type만 넣을 수 있음 (dynamic typing x) a = [1, 2, 3] b = [3, 2, 1] a[0] is b[-1] # True a = np.array(a) b = np.array(b) a[0] is b[-1] # False shape : array의 dimension 반환 (tuple) 1d : (col,), 2d : (row, col), 3d : (channel, row, col)..
Data handling CSV(comma separate value) import csv reader = csv.reader(f, delimiter=',', quotechar='"', quoting=csv.QUOTE_ALL) Regular Expression 010-1234-5678 ^\d{3}\-\d{4}\-\d{4}$ # ^숫자3-숫자4-숫자4$ 소스 보기 , Ctrl + Shift + C 누르고 클릭 - html 상에서 위치 검색 beautifulsoup from bs4 import BeautifulSoup soup = BeautifulSoup(books_xml, "lxml") sop.find_all("author") JavaScript Object Notation(JSON) {"employee" : [ {"firstNa..
Exception/File/Log handling Exception try: except: else: finally: raise (예외 정보) # 강제로 Exception 발생 assert 예외 조건 # 특정 조건을 만족하지 않을 시 예외 발생 File os module, pathlib module File os module, pathlib module Pickle - object 자체를 저장(binary file) import pickle f = open("filename.pickle", "wb") pickle.dump(obj,f) # write f = open("filename.pickle", "rb") obj = pickle.load(f) # read Log import logging logging.debug() # 개발 시 기록 logging.i..