728x90

 

print("the required time: {:.2f}".format(time.time()-start))

studyforus.com/tipnknowhow/661111

 

[Python] 소수점 자리수의 출력 - round() vs format() - Study For Us

파이썬은 반올림을 하는 round() 함수를 내장하고 있습니다.그러나 round() 함수는 끝자리가 0이면 출력을 하지 않는 문제가 있습니다.예컨대 round(3.141592, 2)는 3.14를 출력하지만, round(3.101592, 2)는 3.1

studyforus.com

 

 

728x90
728x90
import time
start = time.time()  # 시작 시간 저장
 
 
# 작업 코드
 
 
print("time :", time.time() - start)  # 현재시각 - 시작시간 = 실행 시간
728x90

'Python' 카테고리의 다른 글

Python 폴더생성/ 하위폴더까지 한꺼번에 생성  (0) 2021.05.03
파이썬 소수점 자리 출력  (0) 2021.05.03
argparse boolean 값 인자로 받기  (0) 2021.05.01
Python 편집기: 찾아바꾸기  (0) 2021.04.29
Numpy slicing  (0) 2021.01.27
728x90
  • OpenCV is BGR, Pillow is RGB
im_bgr = cv2.imread('data/src/lena.jpg')

im_rgb = im_bgr[:, :, [2, 1, 0]]
Image.fromarray(im_rgb).save('data/dst/lena_swap.jpg')

im_rgb = im_bgr[:, :, ::-1] 
Image.fromarray(im_rgb).save('data/dst/lena_swap_2.jpg')

 

note.nkmk.me/en/python-opencv-bgr-rgb-cvtcolor/

 

Convert BGR and RGB with Python, OpenCV (cvtColor) | note.nkmk.me

When the image file is read with the OpenCV function imread(), the order of colors is BGR (blue, green, red). On the other hand, in Pillow, the order of colors is assumed to be RGB (red, green, blue).Therefore, if you want to use both the Pillow function a

note.nkmk.me

 

728x90
728x90

PIL image, cv2

 

(H,W,C)

 

Pytorch

 

(C,H,W)

728x90

'Dic' 카테고리의 다른 글

Sampling / Importance sampling  (0) 2021.04.19
Sampling / Rejection Sampling  (0) 2021.04.19
Sampling / Inverse CDF Method  (0) 2021.04.19
Sampling / Gibbs Sampling  (0) 2021.04.19
negative sampling  (0) 2021.03.21
728x90

eehoeskrap.tistory.com/521

 

[Python] argparse(Argument Parser) 에서 boolean 값 받기

아래와 같이 str2bool 함수를 구현하여 argparse 에서 boolean 값을 받아올 수 있다. def str2bool(v): if isinstance(v, bool): return v if v.lower() in ('yes', 'true', 't', 'y', '1'): return True elif v.l..

eehoeskrap.tistory.com

 

728x90

'Python' 카테고리의 다른 글

파이썬 소수점 자리 출력  (0) 2021.05.03
코드 실행시간 측정  (0) 2021.05.03
Python 편집기: 찾아바꾸기  (0) 2021.04.29
Numpy slicing  (0) 2021.01.27
partial  (0) 2021.01.27
728x90

signing.tistory.com/60

 

[Tips] pyCharm editor 창에서 원하는 문자 바꾸기

R에서는 쉽게 (ctrl) + (F) 로 원하는 문자를 찾아서 바꿀 수 있었는데 pycharm은 그 기능을 몰랐어서 살짝 헤맸었다. 예를 들어 폴더 주소를 복사해서 붙여넣었을 때, 역슬래쉬가 찍히는 것을 볼 수

signing.tistory.com

 

728x90

'Python' 카테고리의 다른 글

코드 실행시간 측정  (0) 2021.05.03
argparse boolean 값 인자로 받기  (0) 2021.05.01
Numpy slicing  (0) 2021.01.27
partial  (0) 2021.01.27
Functools Partial  (0) 2020.09.01
728x90

if __name__=='__main__':

 

# args 선언

(dataset)

-dataset

-dataroot

 

(model)

-model 종류

 

(optimization)

-batch_size

-learning_rate

-step_size

 

(loss)

-loss_function

 

(options)

-seed

-the number of gpu

-use gpu

-eval mode

 

#main

(seed 선언)

(gpu 사용)

(dataset)

(model 선언)

- model

- criterion

 

 

(train)

-train

() load_network

-val

-save_network

 

result save & printing

tensorboard

git

 

 

 

 

 

 

 

 

 

 

 

 

 

728x90

'Pytorch' 카테고리의 다른 글

Pytorch : Variable() 클래스 사용용도 및 의미 (현재는 필요없음)  (0) 2021.09.09
Pytorch : Dataloader num_workers  (0) 2021.06.01
THOP: PyTorch-OpCounter  (0) 2021.04.01
visualization  (0) 2020.08.05
torch.utils.data.DataLoader  (0) 2020.06.20
728x90

Importance sampling은 Rejection sampling이 샘플을 추출할 때, reject하는 비율이 커서 실제로 원하는 양의 sample을 얻는 데 시간이 오래 걸리는 점을 보완한 것이다. 수식의 전개는 아래 참고 자료를 보면 되고, 결과적으로 실제로는 sampling하기 힘든 p(x) 분포대신 q(x)분포를 이용해서 sampling을 진행하는데, q(x)를 통해 samping한 이후에 q(x),p(x)의 비율을 통해 sampling된 수를 조정해준다. 이러한 방법을 취하면 reject하지 않고 일단 sampling한 이후에 sampling한 수의 값을 조정하기 때문에 reject을 해서 시간이 오래 걸렸던 점이 보완된다.

 

 

 

 

blog.naver.com/PostView.nhn?blogId=jinis_stat&logNo=221659748605&categoryNo=14&parentCategoryNo=0&viewDate=&currentPage=1&postListTopCurrentPage=1&from=search

 

Importance Sampling (중요도 샘플링)

앞서 배운 여러가지 Rejection sampling(기각 샘플링) 방법들의 경우, 샘플 추출시 reject(기각)하는 비율...

blog.naver.com

 

jyoondev.tistory.com/150

 

강화학습 - (17) 중요도 샘플링

강화학습 중요도 샘플링 (Importance Sampling) 중요도 샘플링이랑 다른 분포에서 샘플링된 값을 가지고, 구하고자 하는 분포(타깃 분포)에서의 기댓값을 유추하는 방법이다. 랜덤 변수 $x$

jyoondev.tistory.com

 

728x90

'Dic' 카테고리의 다른 글

Image HWC 순서  (0) 2021.05.01
Sampling / Rejection Sampling  (0) 2021.04.19
Sampling / Inverse CDF Method  (0) 2021.04.19
Sampling / Gibbs Sampling  (0) 2021.04.19
negative sampling  (0) 2021.03.21

+ Recent posts