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
>>> # Multi-layer perceptron in Theano see: http://ir.hit.edu.cn/~jguo/docs/notes/a_simple_tutorial_on_theano.pdf | |
>>> import numpy | |
>>> import theano | |
>>> import theano.tensor as T | |
>>> rng = numpy.random | |
>>> N = 400 | |
>>> feats = 784 | |
>>> D = (rng.randn(N, feats), rng.randint(size=N, low=0,high=2) ) | |
>>> training_steps = 10000 | |
>>> x = T.matrix('x') |
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 subprocess import check_output | |
from glob import glob | |
notebooks = glob('./**/*.ipynb', recursive=True) | |
for n in notebooks: | |
cmd = f'jupyter nbconvert --to html {n}' | |
check_output(cmd.split()) |
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
import tensorflow as tf | |
import numpy as np | |
corpus_raw = 'He is the king . The king is royal . She is the royal queen ' | |
# convert to lower case | |
corpus_raw = corpus_raw.lower() | |
words = [] | |
for word in corpus_raw.split(): |
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
# how to use *args and **kwargs with wrapper | |
def main_function(a: int, b: int): | |
print(f'a: {a} + b: {b} = {a+b}') | |
def my_wrapper(*args, **kwargs): | |
print(f'wrapper recieved: {len(args)} args and {len(kwargs)} kwargs') | |
if 'a' not in kwargs: kwargs.update({'a': 6}) |
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
def case_insensitive(s1, s2): | |
""" | |
returns True if both s1 and s2 | |
contain the same letters and letters in the same order, | |
regardless of letters case. | |
In other words, | |
this is an implementation for either | |
s1.upper() == s2.upper() | |
or s1.lower() == s2.lower() | |
""" |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# CREATING A DEDICATED NOTEBOOKS App (for IPYTHON/JUPYTER/JUPYTERLAB) INSTEAD OF THE BROWSER | |
# Fri Sep 30 02:56:42 EDT 2016 | |
# Oftentimes I get lost when I open Python notebooks in the same browser I use to surf the web. | |
# Specially when the tabs start cluttering and growing exponentially with every wild click on every tempting link. | |
# So I wanted to find a way where I can open my notebooks away from the browser's mess. | |
# I tried Pineapple.app (https://nwhitehead.github.io/pineapple/), it's cool. Specially when it comes to opening a notebook instantly just by clicking on its .ipynb file just like any other file. The problem is that Pineapple is not maintained and lack some features. |