This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# 1 Distribution Analysis\n", | |
"\n", | |
"약물 투여 여부를 중심으로 연구를 진행하게 되었다. 기존 근시 환자의 내방 이후 최종 검진 시 SE값을 예측하는 예측모델에 그쳤다면, 여기에 더 나아가 약물사용이 어떻게 모델 예측에 영향력을 미치는지 살펴보는 방향을 진행한다. " | |
] |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing as mp | |
def add(val): | |
list_proxy.append(val) | |
print(list_proxy) | |
if __name__=="__main__": | |
man = mp.Manager() | |
list_proxy = man.list() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Explanations will further be attached. | |
from dataclasses import dataclass, field | |
@dataclass | |
class A: | |
d: int = 3 | |
_e: int = 5 | |
_g: list = field(default_factory=list) | |
def __post_init__(self): | |
self._f = 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reference | |
# https://discuss.pytorch.org/t/how-do-i-check-the-number-of-parameters-of-a-model/4325/8 | |
def count_parameters(model): | |
return sum(p.numel() for p in model.parameters() if p.requires_grad) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from io import BytesIO, StringIO | |
from urllib.request import urlopen | |
from zipfile import ZipFile | |
import pandas as pd | |
def download_and_unzip(url, extract_to='.'): | |
http_response = urlopen(url) | |
zipfile = ZipFile(BytesIO(http_response.read())) | |
return zipfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from torch.utils.data import Dataset, DataLoader | |
import numpy as np | |
class MyDataset(Dataset): | |
def __init__(self): | |
x = np.random.randint(10, size=[1000, 3]) # 1000 3-dim samples | |
self.x = [x[i].tolist() for i in range(1000)] | |
y = np.random.randint(low=0, high=2, size=(1000,)) | |
self.y = [y[i] for i in range(1000)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import random | |
import numpy as np | |
import torch | |
def seed_everything(seed=42): | |
os.environ['PYTHONHASHSEED'] = str(seed) | |
random.seed(seed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def recursive_dfs(v, discovered=[]): | |
discovered.append(v) | |
for w in graph[v]: # for the graph of adjacent matrix | |
if w not in discovered: | |
discovered = recursive_dfs(w, discovered) | |
return discovered # will return the nodes searched in order | |
def iterative_dfs(start_v): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def kill_desktop_ini(root_dir): | |
for (root, dirs, files) in os.walk(root_dir): | |
if len(files) > 0: | |
for file_name in files: | |
if file_name.endswith('.ini'): | |
os.remove(f'{root}/{file_name}') |
NewerOlder