Skip to content

Instantly share code, notes, and snippets.

@ututono
ututono / configs.py
Last active March 2, 2024 11:00
buildtin dynamic configuration
import yaml
import argparse
class Config:
"""
A dynamic configuration class that automatically loads configuration from a YAML file and command line arguments.
Attributes:
_config (dict): A dictionary to store configuration parameters.
@ututono
ututono / basic_logger.py
Last active January 1, 2024 23:04
basic_logger
import logging
import os
import sys
def root_path():
...
class MyFormatter(logging.Formatter):
err_fmt = f"%(asctime)s %(levelname)s %(filename)s @function %(funcName)s line %(lineno)s - %(message)s"
@ututono
ututono / torch_seed_generator.py
Last active September 6, 2023 14:50
Torch Seed Generater
import torch
import numpy as np
import random
def seed_random_generators(seed=SEED):
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
random.seed(seed)
@ututono
ututono / SML_HW04_MLP.py
Last active August 9, 2022 22:02
SML_HW04_MLP
import numpy as np
import os # To improve compatity of the code
import matplotlib.pyplot as plt
class Reader():
def __init__(self):
pass
def load_data(self, foldername):
'''
@ututono
ututono / QA_DEMO.ipynb
Last active August 4, 2022 00:29
QA_DEMO.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import matplotlib.pyplot as plt
import numpy as np
import os
import math
def read_data(BASE='dataSets'):
'''
load data from file
:param BASE: the path of the folder storing the dataset
:return: dict{['train','test']}
'''
import numpy as np
import matplotlib.pyplot as plt
import os
import math
def read_data(BASE='dataSets'):
'''
load data from file
:param BASE: the path of the folder storing the dataset
:return: dict{['train','test']}
import numpy as np
import math
import matplotlib.pyplot as plt
import os
def read_data(BASE='dataSets'):
'''
load data from file
:param BASE: the path of the folder storing the dataset
:return: dict{['train','test']}
import numpy as np
import matplotlib.pyplot as plt
import os
def read_data(BASE='dataSets'):
'''
load data from file
:param parentF: the path of parent folder of the data file
:return: dict{['train','test']}
'''
@ututono
ututono / SimpleSampleForHuggingface.ipynb
Last active November 8, 2022 01:14
SimpleSampleForHuggingface.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.