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 argparse | |
from pathlib import Path | |
import shutil | |
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import torch.optim as optim | |
import torch.utils.tensorboard | |
import torchvision |
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
sbatch --gres=gpu:1 --partition=ziz-gpu-small slurm.sh |
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 audioread as ar | |
import os | |
rootdir = '.' | |
audio_file_formats = ['wav', 'mp3', 'm4a'] | |
for root, subdirs, files in os.walk(rootdir): | |
for filename in files: | |
if filename[-3:] in audio_file_formats: | |
filepath = os.path.join(root, filename) |
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
# lsf bkill all pending jobs | |
bkill `bjobs -p -o jobid | grep -v ^JOBID | tr '\n' ' '` | |
# lsf bkill jobs matching pattern | |
bkill `bjobs -w | grep MultipleGRUs2 | awk '{print $1}' | tr '\n' ' '` | |
# something to do with the largest snapshots in the directory | |
du -sh * | sort -rh | head -n 5 | awk '{print $2"/*.pt"}' | xargs -I@ sh -c 'ls @' |
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
class OrthogonalLinear(nn.Module): | |
""" Implements a non-square linear with orthogonal colums """ | |
def __init__(self, input_size, output_size, lr_factor=0.1): | |
super(OrthogonalLinear, self).__init__() | |
self.input_size = input_size | |
self.output_size = output_size | |
self.max_size = max(self.input_size, self.output_size) | |
self.log_orthogonal_kernel = nn.Parameter(torch.Tensor(self.max_size, self.max_size)) | |
self.log_orthogonal_kernel.register_hook(lambda: print("This should not be executed")) |
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
t = (1, 2, [30, 40]) | |
t[2] += [50, 60] | |
print(t) | |
# Options: | |
# a) t becomes (1, 2, [30, 40, 50, 60]). | |
# b) TypeError is raised with the message 'tuple' object does not support item assignment. | |
# c) Neither. | |
# d) Both a and b. |
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 multiprocessing | |
import subprocess | |
import os | |
def init(queue): | |
global gpuid | |
gpuid = queue.get() | |
gpus_list = list(range(8)) | |
num_gpus = len(gpus_list) |
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
class OnlineStats: | |
# https://www.johndcook.com/blog/standard_deviation/ | |
# Knuth TAOCP vol 2, 3rd edition, page 232 | |
def __init__(self): | |
self.n = 0 | |
def push(self, x): | |
self.n += 1 |
NewerOlder