= 'some_var'
a globals()), ['a']) test_eq(namestr(a,
utils
Utilities needed for little repititive tasks
namestr
namestr (obj, namespace=None)
Returns the name of the object obj
passed
Here’s an example of how namestr
works:
list_files
list_files (startpath)
[simulates the linux tree cmd] (https://stackoverflow.com/questions/9727673/list-directory-tree-structure-in-python)
make_paths
make_paths (path, prefix=None)
with path
as basedir, makes data and models dir and returns a dictionary of relevant pathlib objects
with tempfile.TemporaryDirectory() as tempdirname:
print(f"created temporary dir: {tempdirname}")
= make_paths(Path(tempdirname), "mimic3-9k")
_paths for v in _paths.values(): v.touch()
list_files(tempdirname)
created temporary dir: /tmp/tmpi1evi3rs
tmpi1evi3rs/
data/
mimic3-9k_tok.ft
mimic3-9k_lbl.ft
mimic3-9k.csv
mimic3-9k_tok_lbl.ft
models/
mimic3-9k_dls_clas.pkl
mimic3-9k_dls_lm.pkl
mimic3-9k_lm_r.pth
mimic3-9k_lm_finetuned_r.pth
mimic3-9k_tok_lbl_info.pkl
mimic3-9k_dls_lm_vocab_r.pkl
mimic3-9k_dls_collab.pkl
mimic3-9k_clas.pth
mimic3-9k_dset_clas.pkl
mimic3-9k_dls_lm_vocab.pkl
mimic3-9k_dls_learn_rank.pkl
mimic3-9k_dls_lm_r.pkl
mimic3-9k_dset_clas_r.pkl
mimic3-9k_lm.pth
mimic3-9k_clas_r.pth
mimic3-9k_lm_finetuned.pth
mimic3-9k_dls_clas_r.pkl
collab/
mimic3-9k_collab.pth
plot_hist
plot_hist (data, x_label=None, y_label=None, title='Histogram')
plot_reduction
plot_reduction (X, tSNE=True, n_comps=None, perplexity=30, figsize=(6, 4))
PCA on X and plots the first two principal components, returns the decomposition and the explained variances for each directions, if tSNE
then does a tSNE after PCA.
test_eqs
test_eqs (*args)
1, 1, 9//9) test_eqs(
validate
validate (learner, cb=<class 'fastai.callback.tracker.SaveModelCallback'>)
validates a learner
within a context manager after temporarily removing cb
if it exists
cudamem
cudamem (device=device(type='cpu'))