Skip to content

Instantly share code, notes, and snippets.

View biggzlar's full-sized avatar
🐣
I may be slow to respond.

Lennart biggzlar

🐣
I may be slow to respond.
View GitHub Profile
@biggzlar
biggzlar / soft_arg_max.py
Last active March 8, 2022 10:18
Argmax vs. softargmax (play with beta)
import numpy as np
import matplotlib.pyplot as plt
def softmax(x, beta=1.0):
return np.exp(beta * x) / np.sum(np.exp(beta * x))
def softargmax(x, beta=1.0):
return np.sum((np.exp(beta * x) / np.sum(np.exp(beta * x))) * np.arange(len(x)))
@biggzlar
biggzlar / visualize_convolutional_layers.py
Last active January 30, 2019 10:27
Some snippets on convolutional layer visualization.
import imageio
import numpy as np
from skimage.transform import resize
import tensorflow as tf
# obviously requires a session to run
outs = sess.run(conv0, feed_dict={input : img})
for i in range(32):
# this will size up the filter output to (200, 200) and save it as .png
imageio.imwrite(str(i) + '.png', resize((outs[0,:,:,i] * 200).astype(np.uint8), (200, 200)))
@biggzlar
biggzlar / cuda_installation_on_ubuntu_18.04
Last active March 7, 2021 16:03 — forked from Mahedi-61/cuda_11.8_installation_on_Ubuntu_22.04
tensorflow-gpu and nvidia rtx 2060 / 2070 / 2080
#!/bin/bash
## This gist contains step by step instructions to install cuda v9.0 and cudnn 7.2 in ubuntu 18.04
### steps ####
# verify the system has a cuda-capable gpu
# download and install the nvidia cuda toolkit and cudnn
# setup environmental variables
# verify the installation
###
import numpy as np
from matplotlib import pyplot as plt
mean = [0, 0]
cov = [[1., .5], [.5, 1.]]
m = 128
X = np.random.multivariate_normal(mean, cov, m)
cov = np.cov(X.T)