Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### A Pluto.jl notebook ### | |
# v0.17.4 | |
using Markdown | |
using InteractiveUtils | |
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error). | |
macro bind(def, element) | |
quote | |
local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from skimage.measure import regionprops, label | |
def crop_image(x, threshold=230, plot=True): | |
''' | |
finds large connected components using skimage.measure.label, | |
and displays them with matplotlib.pyplot. | |
''' | |
im = train_images[x] | |
mask = np.where(im > threshold, 1, 0) | |
# now get label_im, a version of the thresholded image, but |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a clunky n-cycle (iterated quine) generator: | |
def quiner(n): | |
'''prints a program that will print itself after n iterations''' | |
quotes = '"'*3 | |
toprint = '' | |
for i in range(1,n): | |
toprint += 'def q' + str(i) + '(x):'""" | |
quotes = '"'*3 | |
print 'q""" + str(i+1) + "(' + quotes + x + quotes + ')'\n\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print (lambda x: x + str((x,)))('print (lambda x: x + str((x,)))',) |