This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This code doesn't work, and isn't intended to. | |
# The goal of this code is to explain how attention mechansisms work, in code. | |
# It is deliberately not vectorized to make it clearer. | |
def attention(self, X_in:List[Tensor]): | |
# For every token transform previous layer's out | |
for i in range(self.sequence_length): | |
query[i] = self.Q * X_in[i] | |
key[i] = self.K * X_in[i] | |
value[i] = self.V * X_in[i] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
git config --global alias.dag "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n' --abbrev-commit --date=relative --branches" | |
# This adds a line to ~/.gitconfig like | |
# [alias] | |
# dag = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n' --abbrev-commit --date=relative --branches |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to use a specific GPU other than the first one. | |
# Put this at the very top of your python script or notebook. | |
# Do this before importing your deep learning libraries. | |
import os | |
os.environ['CUDA_VISIBLE_DEVICES'] = '1' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
git checkout -b main | |
git branch --delete master | |
git push origin main | |
echo "Go to github, Settings, Branches, Default branch, main, update." | |
read -p "Press enter when done: " dontcare | |
git push origin --delete master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
from torch.utils.data import Dataset | |
class BlockCachingDatasetWrapper(Dataset): | |
"""Wraps a pytorch dataset with an LRU cache | |
that fetches an entire block of records at once. | |
""" | |
def __init__(self, base_dataset:Dataset, block_size:int=16): | |
self._dataset = base_dataset |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo zfs allow -s @allperm allow,clone,create,destroy,mount,promote,receive,rename,rollback,send,share,snapshot rustinside | |
sudo zfs allow leo @allperm rustinside |
OlderNewer