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
%% options | |
clear_frames_after = 5; | |
segment = "c"; % can be 'a', 'b', or 'c'. | |
%% diff eqs | |
%because r=1 | |
px = @(t,x) cos(t)-x; | |
py = @(t,y) sin(t)-y; | |
p = @(t,x,y) [px(t,x),py(t,y)]; |
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
%% Constants | |
segments = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"] % replace 'j' with the sub-assignment letter | |
% lowercase only | |
%% A | |
% sun | |
P = [0, 0]; | |
M = 10; | |
% planet | |
p = [1, 0]; |
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
Show hidden characters
{ | |
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and | |
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope | |
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is | |
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. | |
// Placeholders with the same ids are connected. | |
// Example: | |
// "Print to console": { | |
// "scope": "javascript,typescript", |
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 gym | |
import numpy as np | |
import matplotlib.pyplot as plt | |
env_type = "FrozenLake8x8-v0" | |
algorithm_type = "q_learning" | |
policy_type = "epsilon_greedy" | |
run_name = 'run-{0}-{1}-{2}'.format(env_type, algorithm_type, policy_type) | |
# Random seed |
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
"""Graph based autodiff | |
Supports two modes | |
- Forward mode | |
- Reverse mode (much more efficient) | |
We use reverse mode | |
Yet the graph method is still inefficient | |
""" | |
import numpy as np | |
class Expression(): |
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 hashlib | |
import random | |
import string | |
def hash_password(password, salt=None, iterations=100000): | |
""" | |
Hash a string using SHA3-512 | |
input: | |
String: password |
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
import tensorflow as tf | |
tf.reset_default_graph() | |
from tensorflow.examples.tutorials.mnist import input_data | |
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) | |
### model ### | |
# input | |
with tf.name_scope('input') as scope: |
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 flatten(obj): | |
flat = [] | |
if hasattr(obj, '__iter__'): | |
for i in obj: | |
flat.extend(flatten(i)) | |
else: | |
flat.append(obj) | |
return flat |
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 flatten(obj): | |
flat = [] | |
if hasattr(obj, '__iter__'): | |
for i in obj: | |
flat.extend(flatten(i)) | |
else: | |
flat.append(obj) | |
return flat | |
def merge_dicts(list_of_dicts, flat=True): |
NewerOlder