Skip to content

Instantly share code, notes, and snippets.

Avatar

Upul Bandara upul

View GitHub Profile
View dbert_text_classification.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bogdan-kulynych
bogdan-kulynych / install-cuda-10-bionic.sh
Last active Oct 6, 2021
Install CUDA 10 on Ubuntu 18.04
View install-cuda-10-bionic.sh
# WARNING: These steps seem to not work anymore!
#!/bin/bash
# Purge existign CUDA first
sudo apt --purge remove "cublas*" "cuda*"
sudo apt --purge remove "nvidia*"
# Install CUDA Toolkit 10
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.0.130-1_amd64.deb
@goldsborough
goldsborough / conv.cu
Last active Jul 28, 2021
Convolution with cuDNN
View conv.cu
#include <cudnn.h>
#include <cassert>
#include <cstdlib>
#include <iostream>
#include <opencv2/opencv.hpp>
#define checkCUDNN(expression) \
{ \
cudnnStatus_t status = (expression); \
if (status != CUDNN_STATUS_SUCCESS) { \
View probabilistic_pca.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@altosaar
altosaar / black_box_vi_bayesian_linear_regression.py
Created Feb 11, 2017
Black box variational inference for Bayesian linear regression. Numpy and scipy only.
View black_box_vi_bayesian_linear_regression.py
"""Use black-box variational inference (https://arxiv.org/abs/1401.0118) to
fit Bayesian linear regression (https://en.wikipedia.org/wiki/Bayesian_linear_regression)
and ensure it gets the analytic posterior mean from wikipedia.
"""
import numpy as np
import scipy.stats
def generate_data(cfg):
"""synthetic data:
@siemanko
siemanko / tf_lstm.py
Last active Jun 3, 2020
Simple implementation of LSTM in Tensorflow in 50 lines (+ 130 lines of data generation and comments)
View tf_lstm.py
"""Short and sweet LSTM implementation in Tensorflow.
Motivation:
When Tensorflow was released, adding RNNs was a bit of a hack - it required
building separate graphs for every number of timesteps and was a bit obscure
to use. Since then TF devs added things like `dynamic_rnn`, `scan` and `map_fn`.
Currently the APIs are decent, but all the tutorials that I am aware of are not
making the best use of the new APIs.
Advantages of this implementation:
@twiecki
twiecki / bayesian_neural_network.ipynb
Last active May 4, 2020
Bayesian Neural Network in PyMC3
View bayesian_neural_network.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@parmentf
parmentf / GitCommitEmoji.md
Last active Oct 16, 2021
Git Commit message Emoji
View GitCommitEmoji.md
@danoneata
danoneata / visitor.py
Created Nov 19, 2015
Visitor pattern in Python
View visitor.py
class Expr(object):
def accept(self, visitor):
method_name = 'visit_{}'.format(self.__class__.__name__.lower())
visit = getattr(visitor, method_name)
return visit(self)
class Int(Expr):
def __init__(self, value):
self.value = value
@karpathy
karpathy / min-char-rnn.py
Last active Oct 15, 2021
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
View min-char-rnn.py
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)