Skip to content

Instantly share code, notes, and snippets.

View rohitdavas's full-sized avatar
🏠
Working from home

Rohit Davas rohitdavas

🏠
Working from home
View GitHub Profile
@rohitdavas
rohitdavas / catastrohpic-forgetting.ipynb
Last active May 3, 2023 21:40
catastrohpic-forgetting.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rohitdavas
rohitdavas / Vimium_chetsheet.txt
Last active April 12, 2023 12:16
Vimium cheatsheet for print
loaded from https://github.com/philc/vimium/blob/master/README.md
? show the help dialog for a list of all available keys
h scroll left
j scroll down
k scroll up
l scroll right
gg scroll to top of the page
G scroll to bottom of the page
d scroll down half a page
@rohitdavas
rohitdavas / requriments_gen.sh
Created April 12, 2023 08:36
creating a requirements.txt for python
# the package you need is pipreqs
pip install pipreqs
# they have a number of arguments. the most useful i found
# is the argument allowing you to check your package on pypi server.
# this fixed bugs in the requriements.txt packages. e.g skimage is not a package, but pipreqs was listing it down
# another is the version number listed by the pipreqs might be messed up.
python -m pipreqs.pipreqs . --force --mode gt --pypi-server https://pypi.org/
@rohitdavas
rohitdavas / balanced_BCE_loss.py
Created February 9, 2023 09:33
Balanced Binary cross entropy loss function
"""
This is simple implementation of a binary cross entropy.
Test cases : done.
"""
import torch
def balanced_BCE_loss(predictions: torch.Tensor, ground_truth: torch.Tensor, with_logits=False) -> torch.Tensor:
"""
@rohitdavas
rohitdavas / simple-self-attention.py
Last active January 22, 2023 04:57
SImple Self-Attention with vectorised form understanding
# %%
import torch
import torch.nn.functional as F # for using softmax
cc = torch.manual_seed(0) # for reproducibility
# somehow on my m1 mac, the randomness is not reproducible. todo: figure out why
b = 1 # mini batch size
t = 3 # sequence length
k = 2 # dimension of each vector in the sequence