Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Recsys-KR
- pytorch
- 한빛미디어
- MySQL
- hackerrank
- DilatedNet
- 3줄 논문
- 나는리뷰어다
- 추천시스템
- 스택
- TEAM-EDA
- 협업필터링
- 파이썬
- Semantic Segmentation
- 코딩테스트
- DFS
- 나는 리뷰어다
- Machine Learning Advanced
- Python
- 엘리스
- 프로그래머스
- 큐
- 튜토리얼
- Segmentation
- TEAM EDA
- eda
- Object Detection
- 입문
- Image Segmentation
- 알고리즘
Archives
- Today
- Total
TEAM EDA
파이썬 시드 고정 본문
파이썬 및 파이토치의 시드를 고정해주는 명령어
# Update 코드
# 링크 : https://www.kaggle.com/reighns/complete-and-reusable-pytorch-pipeline
def seed_all(seed: int = 1930):
print("Using Seed Number {}".format(seed))
os.environ["PYTHONHASHSEED"] = str(
seed) # set PYTHONHASHSEED env var at fixed value
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
torch.cuda.manual_seed(seed) # pytorch (both CPU and CUDA)
np.random.seed(seed) # for numpy pseudo-random generator
random.seed(
seed) # set fixed value for python built-in pseudo-random generator
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
torch.backends.cudnn.enabled = False
def seed_worker(_worker_id):
worker_seed = torch.initial_seed() % 2**32
np.random.seed(worker_seed)
random.seed(worker_seed)
seed_all(seed=1994)
'EDA Study > 코드' 카테고리의 다른 글
| 2차원 리스트의 Transpose 구하기 (0) | 2020.12.29 |
|---|---|
| 2차원의 배열을 1차원의 배열로 바꾸는 코드 (0) | 2020.12.28 |
| 구글 드라이브의 이미지 외부링크 추출 (0) | 2020.12.27 |
| 파이썬 메모리 줄이는 코드 (정형데이터) (0) | 2020.12.25 |
| 파이썬 경고 무시 (0) | 2020.12.25 |