This file contains 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 |
This file contains 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 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 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 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 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 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
from functools import lru_cache | |
import subprocess | |
from torch.utils.data import Dataset | |
class FileReaderDataset(Dataset): | |
"""Exposes a line-delimited text file as a PyTorch Dataset. | |
Maintains an LRU cache of lines it has read, while supporting random access into | |
files too large to hold in memory. Memory requirement still scales by O(N), but just | |
for pointers into the file, about 8 bytes per line. After the file has been scanned, | |
random access will be very fast - as fast as the disk plus the OS's cache of it. |
This file contains 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
set -o vi # Switch bash to vi mode |
This file contains 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
" turn off compatibility with the old vi | |
set nocompatible | |
set ts=4 | |
set et | |
" turn syntax highlighting on by default | |
syntax on | |
" set auto-indenting on for programming |
This file contains 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
count_by = function(collection,field) { | |
return collection.aggregate({ | |
$group: { | |
_id: "$" + field, | |
count: { $sum: 1 } | |
} | |
}) | |
} | |
count_by(db.vid10,'char'); |
NewerOlder