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 continuumio/miniconda3 | |
RUN apt update -qq && apt install -y libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6 build-essential vim curl wget libhdf5-dev | |
RUN useradd -m docker -s /bin/bash -p '*' && chown -R 1000:1000 /opt/conda | |
USER docker | |
RUN conda create -n env python=3.8 && RUN echo "source activate env" > ~/.bashrc | |
ENV PATH /opt/conda/envs/env/bin:$PATH |
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 pearson(x, y): | |
'''Metric for correlation coefficient. | |
Use as follows: | |
model.compile(loss='mse', optimizer='adam', metrics=[pearson]) | |
''' | |
mx = K.mean(x) | |
my = K.mean(y) | |
xm, ym = x-mx, y-my | |
r_num = K.sum(tf.multiply(xm,ym)) | |
r_den = K.sqrt(tf.multiply(K.sum(K.square(xm)), K.sum(K.square(ym)))) |
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 numpy as np | |
from tensorflow.keras import backend as K | |
from tensorflow.python.keras.layers import InputSpec, Layer | |
class Argmax(Layer): | |
""" | |
Based on https://github.com/YerevaNN/R-NET-in-Keras/blob/master/layers/Argmax.py | |
""" | |
def __init__(self, axis=-1, **kwargs): | |
super(Argmax, self).__init__(**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
import kotlinx.coroutines.* | |
fun run() = runBlocking { | |
val l: List<Deferred<Int>> = List(100_000) { | |
async { | |
delay(1000) | |
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
find $DIR -type f -exec stat -f "%z %N" {} \; | sort -nr | head -100 |
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
java_exec=$(readlink -f `which javac`) | |
export JAVA_HOME="${java_exec::-10}" |
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 | |
# run this script from the master node | |
cluster = tf.train.ClusterSpec({"distributed": ["192.168.102.90:1111", "192.168.102.90:1111"]}) | |
x = tf.constant(2) | |
with tf.device("/job:local/replica:0/task:0/device:GPU:0"): #"/job:distributed/task: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
#include <fiberize/fiberize.hpp> | |
#include <iostream> | |
// after https://github.com/fiberize/fiberize/blob/master/fiberize/examples/helloworld/main.cpp | |
using namespace fiberize; | |
#define VECTOR_SIZE 100 | |
int vector[VECTOR_SIZE] |
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 tensorflow.python.keras.layers import ZeroPadding1D, Concatenate, Reshape, TimeDistributed, LSTM, Dropout, Masking, Cropping1D | |
from tensorflow.python.keras.regularizers import l1 | |
reg = l1(10e-5) | |
def mini_bert_block( | |
input_layer, embedding_dim=300, | |
drop_out=0.5, sequence_length=800, context_width=3, | |
): | |
if (context_width % 2) == 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
docker pull tensorflow/tensorflow:1.13.1-gpu-py3-jupyter # or find one here: https://hub.docker.com/r/tensorflow/tensorflow/tags | |
docker run --runtime=nvidia --name jupyter_ben -d -v /bigusers/ben_again:/home/ben -v /catwalk:/catwalk -v /bigusers/ben:/ben -v /vX:/vX -v /u02/bigdata:/u02 -p 5051:8888 tensorflow/tensorflow:1.13.1-gpu-py3-jupyter | |
docker logs jupyter_ben # to see the token for identification |