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
#durty timing stuff around the code | |
import time | |
class Timer: | |
times = {} | |
@staticmethod | |
def start(key=''): | |
if key not in Timer.times: | |
Timer.times[key] = {'start': False, 'sum': 0} |
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 IPython import display | |
plt.plot(data) | |
display.clear_output(wait=True) | |
display.display(plt.gcf()) | |
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 | |
batch_size = 2 | |
get_single_xy_timeout = 10 | |
train_timeout = 3 | |
n_epochs = 5 | |
n_threads = 5 | |
# dummy function simulating loading, preprocessing | |
# and other operations needed for the X and Y |
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
# Implementation of a rotating buffer on the GPU of size 2. | |
import threading | |
import tensorflow as tf | |
from tensorflow.python.client import timeline | |
import numpy as np | |
import time | |
params = { | |
'batch_size': 128, | |
'seg_len': 4000, |
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 lrelu(x, leak=0.1): | |
f1 = 0.5 * (1 + leak) | |
f2 = 0.5 * (1 - leak) | |
return f1 * x + f2 * abs(x) | |
def lrelu(x, leak = 0.1): | |
return tf.maximum(leak*x, x) |
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 find_primes(n): | |
is_prime = np.ones(n, dtype=bool) | |
# remove 0 and 1 because we know they are not prime | |
is_prime[0:2] = False | |
# start from number 2 | |
for number in range(2 , n): | |
if number**2 > n: break | |
if is_prime[number]: | |
is_prime[number*2::number] = False |
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
# download a file with max bandwidth | |
aria2c --file-allocation=none -c -x 10 -s 10 URL | |
# disk inventory | |
ncdu |
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
## list all drives and find /dev/sdXY for the external | |
sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL | |
## Install hfsprogs to read HFS+ (apple's file system) | |
sudo apt-get install hfsprogs | |
## mount | |
sudo mount -t hfsplus -o force,rw /dev/sdXY /media/external | |
## or | |
sudo mount -t exfat -o force,rw /dev/sdXY /media/external | |
## if the drive was improperly unmounted or a little corrupted | |
# sudo fsck.hfsplus -f /dev/sdXY |
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
fig = plt.gcf() # get current figure | |
ax = plt.gca() # get current axis |
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
Generate a rsa keypair: | |
# ssh-keygen | |
then copy it on the server with one simple command: | |
# ssh-copy-id hostname | |
you can now log in without password: | |
# ssh hostname |
OlderNewer