Skip to content

Instantly share code, notes, and snippets.

@yang-zhang
yang-zhang / pytorch-losses-in-plain-python.ipynb
Last active December 21, 2022 07:14
git/yang-zhang.github.io/ds_code/pytorch-losses-in-plain-python.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yang-zhang
yang-zhang / add_destination.md
Last active July 23, 2018 02:24
Add destination to commands
tar -xf archive.tar -C /target/directory

wget url -P /path/to/folder

gunzip -c file.gz > /THERE/file

unzip source.zip -d /path/to/folder
@yang-zhang
yang-zhang / sample_dict.py
Created July 9, 2018 13:53
Randomly sample a dictionary
def sample_dct(dct, n=3):
idx = np.random.choice(len(dct), n)
return dict(np.array(list(dct.items()))[idx])
@yang-zhang
yang-zhang / pytorch_references.md
Last active July 5, 2018 02:23
Pytorch references

for i, l in enumerate(self.linears):

@yang-zhang
yang-zhang / pluralsight_advanced_python_course_notes.md
Created June 23, 2018 01:22
Pluralsight advanced Python course notes

while else # nobreak

@yang-zhang
yang-zhang / fastai_ml_course_notes.md
Last active December 27, 2020 20:55
fast.ai machine learning course notes
@yang-zhang
yang-zhang / dict2df.py
Created June 20, 2018 15:19
Convert a dictionary to pandas dataframe
dict_ = {'001.jpg': 'dog', '002.jpg': 'cat', }
df = pd.DataFrame.from_dict(dict_, orient='index').reset_index()
df.columns = ['image_name', 'tags']
@yang-zhang
yang-zhang / cheat_sheet_pickle.py
Created June 12, 2018 20:32
Cheatsheet pickle
pickle.dump(something, open('something.p', 'wb'))
something = pickle.load(open('something.p', 'rb'))