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
find . -name '*.png' | while read line; do echo ${line}; convert -resize 70% ${line} ${line}.small.png; pngquant --speed 1 ${line}.small.png -o ${line}.quant.png; done | |
find . -name '*.small.png' | while read line; do rm $line; done | |
read -p "Press [Enter] if you are happy with *.quant.png images, otherwise press Ctrl-C." | |
find . -name '*.quant.png' | while read line; do mv ${line} ${line:0:-10}; done | |
for EXT in png pdf; do find -name "*.${EXT}" | while read line; do echo $line; done; done | while read line; do if ! grep -q -r --include \*.tex ${line#*/} .; then echo ${line}; rm ${line}; fi; done |
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
use std::error::Error; | |
enum TaskError<'a, C> { | |
CustomError(C), | |
StdError(Box<dyn Error + 'a>) | |
} | |
type TaskResult<'a, R, E> = std::result::Result<R, TaskError<'a, E>>; | |
impl<'a, E: Error + 'a, C> From<E> for TaskError<'a, C> { |
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
a=(x y z); b=(q w e); for i in ${!a[@]}; do echo ${a[i]}-${b[i]}; done |
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 sys | |
import glob | |
import tqdm | |
import imageio | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import tensorflow as tf |
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 tensorflow as tf | |
import tensorflow_datasets as tfds | |
spec = tfds.features.FeaturesDict({ | |
'image': tfds.features.Tensor(shape=(28, 28, 1), dtype=tf.float32), | |
'label': tfds.features.ClassLabel(names=['no', 'yes']), | |
'metadata': { | |
'id': tf.int64, | |
'language': tf.string, | |
}, |
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
def run_release_gpu(func): | |
def parallel_wrapper(output_dict, *argv, **kwargs): | |
ret = func(*argv, **kwargs) | |
if ret is not None: | |
output_dict['ret'] = ret | |
def outer_wrapper(*argv, **kwargs): | |
same_process = kwargs.pop('same_process', False) | |
if same_process: | |
return func(*argv, **kwargs) |
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
#!/usr/bin/bash | |
watch "nvidia-smi | tail -n +7; nvidia-smi | nvidia-smi | sed -n '/| Processes:/,\$p' | tail -n +4 | head -n -1 | awk '{print \$3}' | while read line; do ps a -o pid,user | grep \$line | grep -v grep; done | |
" |
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 datetime | |
import linecache | |
import os | |
import pynvml3 | |
import torch | |
print_tensor_sizes = True | |
last_tensor_sizes = set() | |
gpu_profile_fn = f'{datetime.datetime.now():%d-%b-%y-%H:%M:%S}-gpu_mem_prof.txt' |
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
backtick 0 0 0 whoami | |
caption always "%{-b ..}%-w%{+b ..}[[%n%f*%t]]%{-}%+w %= %0`@%H | %l" | |
bind ` focus prev |
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
# based on https://github.com/google/seq2seq/blob/master/bin/tools/generate_beam_viz.py | |
# extracts probabilities and sequences from .npz file generated during beam search. | |
# and pickles a list of the length n_samples that has beam_width most probable tuples | |
# (path, logprob, prob) | |
# where probs are scaled to 1. | |
import numpy as np | |
import networkx as nx | |
import pickle |
NewerOlder