Skip to content

Instantly share code, notes, and snippets.

View danielwatson6's full-sized avatar
💭
GitLab: danielwatson6

Daniel Watson danielwatson6

💭
GitLab: danielwatson6
View GitHub Profile
"""Optimizer to find the closest sigmoidal function to the identity."""
import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf
LEARNING_RATE = 1e-3 # make this small to make optimization converge.
BATCH_SIZE = 10000 # make this big to make optimization more accurate.
STEPS = 1000 # increase this if the learning rate is too small.
def split_by_delimiter(ts, delimiter):
"""Split a numeric tensor similarly to python's `str.split` method."""
ts_str = tf.reshape(tf.reduce_join(tf.as_string(ts), separator=' '), [-1])
ts_slices = tf.string_split(
tf.string_split(ts_str, delimiter=str(delimiter)).values)
result = tf.SparseTensor(
ts_slices.indices,
tf.string_to_number(ts_slices.values, out_type=ts.dtype),
ts_slices.dense_shape)
"""Automatically build a vanilla or Cudnn RNN."""
import numpy as np
import tensorflow as tf
def gru(inputs,
num_layers,
num_units,
direction='unidirectional',
// Copy paste this into the JS console of any window that has loaded
// https://coinmarketcap.com/
var CURRENCY = 'bitcoin';
var w = window.open('https://coinmarketcap.com/currencies/' + CURRENCY + '/historical-data/?start=20000101&end=20170806');
w.addEventListener('load', function () {
var rows = $(w.document.getElementById('historical-data')).find('tr');
# Biology IA Simulations
# By Daniel Watson
import numpy
import matplotlib.pyplot as plt
# Controlled variables
h = .1 # days (step size)
population = 3.9e6 # remains constant
mosquitoes = 1e8 # remains constant
### Code for passing through edit pages
# Handle a PUT request.
def put(self, *args):
BaseController.put(self, *args)
# Form is a dictionary with elements like
# property_name: list_of_validators.
form = self.model.form
from lib import db, utils
from lib.db import validators
BOOK_EXTENSIONS = ['azw', 'azw1', 'azw4', 'epub', 'kf8', 'mobi', 'pdb', 'pdf', 'prc', 'tpz']
class BookModel(db.BlobModel):
### Data:
###
### This is an example on how to use blobs with the webapp_enhanced project
### Author: djwatt5
###
### Most of the content here can be automatically generated
### using the console tool from webapp_enhanced. The only
### piece of code below that is custom can be found in the
### `self.create()` method (see line 43).
###
@danielwatson6
danielwatson6 / weekday.py
Created May 22, 2013 22:17
Calculate the weekday of any given date
# Calculate the weekday of any given date
# Author: djwatt5
# We use the floor method from the math module
# to calculate the year offset.
import math
# Format: day: 1-31, month: 1-12, year: 1-
# String option: if not specified, the result
# will be an integer (Sunday: 0, Monday: 1, ...,