Skip to content

Instantly share code, notes, and snippets.

View evanthebouncy's full-sized avatar
💯
每人都发小红花

evanthebouncy

💯
每人都发小红花
View GitHub Profile
@dgrtwo
dgrtwo / mnist_pairs.R
Created May 31, 2017 18:56
Comparing pairs of MNIST digits based on one pixel
library(tidyverse)
# Data is downloaded from here:
# https://www.kaggle.com/c/digit-recognizer
kaggle_data <- read_csv("~/Downloads/train.csv")
pixels_gathered <- kaggle_data %>%
mutate(instance = row_number()) %>%
gather(pixel, value, -label, -instance) %>%
extract(pixel, "pixel", "(\\d+)", convert = TRUE)
def request_(req_url, sleep_time=1):
succeeded = False
while not succeeded:
try:
print("Requesting: %s" % req_url)
request = Request(req_url)
request.add_header('User-Agent',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36')
response = urlopen(request)
out = response.read().decode(