Skip to content

Instantly share code, notes, and snippets.

View leriomaggio's full-sized avatar
🧙

Valerio Maggio leriomaggio

🧙
View GitHub Profile
@leriomaggio
leriomaggio / multiprocessing_seed_numpy.py
Last active April 11, 2021 11:34
Python and Random State Sharing with NumPy and PyTorch, depending on different multiprocessing start method (i.e. fork vs spawn)
import numpy as np
import multiprocessing as mp
from argparse import ArgumentParser
def get_current_seed(wid):
s = np.random.get_state()[1][0]
print(f"Pool Worker {wid}: Random State {s}")
@leriomaggio
leriomaggio / lazy_filter.md
Last active December 12, 2022 11:06
Functional Python Lazy Filtering pipeline

Case Study: Textual Data

Now it is time to crack on with our first case study 🙌.

Assume we have some data in textual format that we want to use as input to some ML model. To make it even more fun, instead of working with standard textual data, let's imagine we have some source code listings we want to process.

Our examplar data will be two functions, written in our most favourite programming language$^5$: init_random_weights_tensor, and init_random_weights_array:

[5]: Examples adapted from Learning PyTorch with Examples tutorial.

@leriomaggio
leriomaggio / solved-flower-hands-on-tutorial-pytorch.ipynb
Created June 19, 2023 04:08
SOLVED:Flower Hands-on Tutorial-PyTorch.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.