Skip to content

Instantly share code, notes, and snippets.

Kasper Fredenslund kasperfred

Block or report user

Report or block kasperfred

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ml84.m
%% 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)];
View ml98.m
%% 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];
@kasperfred
kasperfred / greek_letters.jsonc
Last active Feb 26, 2019
Autocomplete for latex-like greek letters.
View greek_letters.jsonc
{
// 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",
View q_learning.py
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
View looking at german streetsigns.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View autodiff.py
"""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():
View genius.py
# Import a bunch of models
from sklearn.linear_model import LinearRegression
from sklearn.svm import SVR
from sklearn.neighbors import KNeighborsRegressor
from sklearn.tree import DecisionTreeRegressor
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.cross_decomposition import PLSRegression
from sklearn.ensemble import AdaBoostRegressor
View password_hash.py
import hashlib
import random
import string
def hash_password(password, salt=None, iterations=100000):
"""
Hash a string using SHA3-512
input:
String: password
View mnist_tensorboard_demo.py
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:
View merge_dicts.py
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):
You can’t perform that action at this time.