Skip to content

Instantly share code, notes, and snippets.

View myazdani's full-sized avatar
🏠
ML

Mehrdad Yazdani myazdani

🏠
ML
View GitHub Profile
@myazdani
myazdani / torch-multinomial-picking-0-prob-element.ipynb
Created April 20, 2023 20:47
torch.multinomial picking 0 prob element.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@myazdani
myazdani / -1-trick-for-masking-subsets-of-sequence-for-loss.ipynb
Created March 29, 2023 05:18
-1 trick for masking subsets of sequence for loss.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@myazdani
myazdani / computing-jacobians-different-ways.ipynb
Created November 21, 2022 07:46
computing-jacobians-different-ways.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@myazdani
myazdani / approximate-7up-embedding.ipynb
Created December 6, 2020 17:38
approximate-7UP-embedding.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@myazdani
myazdani / ridge.py
Last active September 26, 2023 13:39
Ridge regression in PyTorch
import torch
from torch import nn
import torch.nn.functional as F
class Ridge:
def __init__(self, alpha = 0, fit_intercept = True,):
self.alpha = alpha
self.fit_intercept = fit_intercept
def fit(self, X: torch.tensor, y: torch.tensor) -> None:
import argparse
from loguru import logger
parser = argparse.ArgumentParser(description='Minimal example of dumping args into log file.')
parser.add_argument('--flag',type=str,
help='Some parameter flag')
args = parser.parse_args()
logger.add("file_{time}.log")
for arg, value in sorted(vars(args).items()):
@myazdani
myazdani / plotly-figure-representation.ipynb
Created April 5, 2020 22:29
plotly-figure-representation.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@myazdani
myazdani / notes.txt
Created March 24, 2020 18:55
Working out a toy example on do-calculus for smoking causing cancer from Pearl's book "Book of Why"
p(c = True | tar = True, smoking = True) = 0.99
p(c = True | tar = False, smoking = True) = 0.2
p(c = True | tar = False, smoking = False) = 0.01
p(c = True | tar = True, smoking = False) = 0.99
p(smoking = True) = 0.1
p(smoking = False) = 0.9
p(tar = True | smoking = True) = 0.99
p(tar = False | smoking = True) = 0.01
@myazdani
myazdani / father_son_heights.tsv
Created December 2, 2019 23:10
Tab separated data of father and son heights as collected by Karl Pearson.
Father Son
65.0 59.8
63.3 63.2
65.0 63.3
65.8 62.8
61.1 64.3
63.0 64.2
65.4 64.1
64.7 64.0
66.1 64.6
@myazdani
myazdani / time-stamped-logdir.py
Created November 5, 2019 12:29
Creating a unique name for a logging based on current time stamp.
from datetime import datetime
now = datetime.utcnow().strftime("%Y%m%d%H%M%S")
root_logdir = "tf_logs"
logdir = "{}/run-{}/".format(root_logdir, now)