Skip to content

Instantly share code, notes, and snippets.

View rasbt's full-sized avatar

Sebastian Raschka rasbt

View GitHub Profile
@rasbt
rasbt / vgg16.py
Created March 3, 2019 06:34
Speed comparison DataLoader vs in-memory
import time
import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision import datasets
from torchvision import transforms
from torch.utils.data import DataLoader
if torch.cuda.is_available():
@rasbt
rasbt / ipnbdoctest.py
Created March 9, 2017 17:38 — forked from minrk/ipnbdoctest.py
simple example script for running and testing notebooks.
#!/usr/bin/env python
"""
simple example script for running and testing notebooks.
Usage: `ipnbdoctest.py foo.ipynb [bar.ipynb [...]]`
Each cell is submitted to the kernel, and the outputs are compared with those stored in the notebook.
"""
# License: Public Domain, but credit is nice (Min RK).
@rasbt
rasbt / plot_decision_region_bug_1.py
Created September 13, 2016 14:39
plot_decision_region bug
from matplotlib.colors import ListedColormap
import matplotlib.pyplot as plt
import numpy as np
from sklearn import datasets
from sklearn.linear_model import LogisticRegression
def plot_decision_regions(X, y, classifier, resolution=0.1):
# setup marker generator and color map
markers = ('s', 'x', 'o', '^', 'v')
@rasbt
rasbt / eng_detect.py
Last active August 29, 2015 14:07
English language detection
import nltk
def eng_ratio(text):
''' Returns the ratio of non-English to English words from a text '''
english_vocab = set(w.lower() for w in nltk.corpus.words.words())
text_vocab = set(w.lower() for w in text.split() if w.lower().isalpha())
unusual = text_vocab.difference(english_vocab)
diff = len(unusual)/len(text_vocab)
return diff
@rasbt
rasbt / .vimrc
Last active August 28, 2017 10:12
vimrc file for c++ and python code syntax support
" Sebastian Raschka
" 09/11/2013
"
syntax on
set nonumber
set ruler
set tabstop=4
set shiftwidth=4 " controls the depth of autoindentation