Skip to content

Instantly share code, notes, and snippets.

View rasbt's full-sized avatar

Sebastian Raschka rasbt

View GitHub Profile
@Beneboe
Beneboe / how-to-setup-verified-commits.md
Last active March 20, 2024 18:20
How to Setup Verified Commits on Github
@ikhlestov
ikhlestov / weights_initialization.py
Created September 12, 2017 17:18
pytorch: weights initialization
import torch
from torch.autograd import Variable
# new way with `init` module
w = torch.Tensor(3, 5)
torch.nn.init.normal(w)
# work for Variables also
w2 = Variable(w)
torch.nn.init.normal(w2)
# old styled direct access to tensors data attribute
@gati
gati / guess_candidate_model.py
Created November 2, 2016 15:42
Code for training an LSTM model for text classification using the keras library (Theano backend). Was used for guesscandidate.com.
from sklearn.cross_validation import train_test_split
from keras.preprocessing import sequence, text
from keras.models import Sequential
from keras.layers import (Dense, Dropout, Activation, Embedding, LSTM,
Convolution1D, MaxPooling1D)
# Embedding
max_features = 20000
maxlen = 100
embedding_size = 32
@kastnerkyle
kastnerkyle / handwriter.py
Last active September 4, 2019 18:57
Single file handwriting experiment
# Author: Kyle Kastner
# License: BSD 3-clause
# Thanks to Jose (@sotelo) for tons of guidance and debug help
# Credit also to Junyoung (@jych) and Shawn (@shawntan) for help/utility funcs
# Strangeness in init could be from onehots, via @igul222. Ty init for one hot layer as N(0, 1) just as in embedding
# since oh.dot(w) is basically an embedding
import os
import re
import tarfile
from collections import Counter
@erikbern
erikbern / install-tensorflow.sh
Last active June 26, 2023 00:40
Installing TensorFlow on EC2
# Note – this is not a bash script (some of the steps require reboot)
# I named it .sh just so Github does correct syntax highlighting.
#
# This is also available as an AMI in us-east-1 (virginia): ami-cf5028a5
#
# The CUDA part is mostly based on this excellent blog post:
# http://tleyden.github.io/blog/2014/10/25/cuda-6-dot-5-on-aws-gpu-instance-running-ubuntu-14-dot-04/
# Install various packages
sudo apt-get update
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@honnibal
honnibal / theano_mlp_small.py
Last active March 1, 2023 15:10
Stripped-down example of Multi-layer Perceptron MLP in Theano
"""A stripped-down MLP example, using Theano.
Based on the tutorial here: http://deeplearning.net/tutorial/mlp.html
This example trims away some complexities, and makes it easier to see how Theano works.
Design changes:
* Model compiled in a distinct function, so that symbolic variables are not in run-time scope.
* No classes. Network shown by chained function calls.
@ethanwhite
ethanwhite / git_head_hash.py
Created June 29, 2014 02:56
Get hash of current git HEAD using Python built-ins
import subprocess
process = subprocess.Popen(['git', 'rev-parse', 'HEAD'], shell=False, stdout=subprocess.PIPE)
git_head_hash = process.communicate()[0].strip()
@kracekumar
kracekumar / Writing better python code.md
Last active February 19, 2024 03:06
Talk I gave at June bangpypers meetup.

Writing better python code


Swapping variables

Bad code

#!/usr/bin/python
# -*- coding: utf-8 -*-
import subprocess
__all__ = ["transform"]
__version__ = '0.3'
__author__ = 'Christoph Burgmer <cburgmer@ira.uka.de>'
__url__ = 'http://github.com/cburgmer/upsidedown'