class LossHistory(Callback):
def __init__(self, X_train, y_train, layer_index):
super(Callback, self).__init__()
self.layer_index = layer_index
if X_train.shape[0] >= 1000:
mask = np.random.choice(X_train.shape[0], 1000)
self.X_train_subset = X_train[mask]
self.y_train_subset = y_train[mask]
else:
This file contains hidden or 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 random | |
| class TicTacToe: | |
| def __init__(self, playerX, playerO): | |
| self.board = [' ']*9 | |
| self.playerX, self.playerO = playerX, playerO | |
| self.playerX_turn = random.choice([True, False]) | |
| def play_game(self): |
This file contains hidden or 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
| """ | |
| The MIT License (MIT) | |
| Copyright (c) 2015 Alec Radford | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is |
This file contains hidden or 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
| #!/usr/bin/python3 | |
| # By Steve Hanov, 2011. Released to the public domain. | |
| # Please see http://stevehanov.ca/blog/index.php?id=115 for the accompanying article. | |
| # | |
| # Based on Daciuk, Jan, et al. "Incremental construction of minimal acyclic finite-state automata." | |
| # Computational linguistics 26.1 (2000): 3-16. | |
| # | |
| # Updated 2014 to use DAWG as a mapping; see | |
| # Kowaltowski, T.; CL. Lucchesi (1993), "Applications of finite automata representing large vocabularies", | |
| # Software-Practice and Experience 1993 |
This file contains hidden or 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 numpy as np | |
| #from scipy.special import chdtrc | |
| from scipy.sparse import spdiags | |
| from sklearn.base import BaseEstimator, TransformerMixin | |
| from sklearn.preprocessing import LabelBinarizer | |
| def _chisquare(f_obs, f_exp, reduce): | |
| """Replacement for scipy.stats.chisquare with custom reduction. |
This file contains hidden or 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 simple implementation of a greedy transition-based parser. Released under BSD license.""" | |
| from os import path | |
| import os | |
| import sys | |
| from collections import defaultdict | |
| import random | |
| import time | |
| import pickle | |
| SHIFT = 0; RIGHT = 1; LEFT = 2; |
This file contains hidden or 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
| # Incomplete row major matrix implementation. | |
| type RowMajorMatrix{T} <: AbstractMatrix{T} | |
| col_major::Matrix{T} | |
| end | |
| row_major{T}(c::Matrix{T}) = RowMajorMatrix{T}(c) | |
| Base.size{T}(m::RowMajorMatrix{T}, n::Int) = if n == 1 size(m.col_major, 2) elseif n == 2 size(m.col_major, 1) else size(m.col_major, n) end | |
| Base.getindex{T}(m::RowMajorMatrix{T}, i, j) = m.col_major[j, i] | |
| function setindex!{T}(m::RowMajorMatrix{T}, value, i, j) |
This file contains hidden or 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
| module HMM | |
| using Distributions | |
| import Distributions.rand | |
| import Distributions.fit | |
| immutable HiddenMarkovModel{TP, K} | |
| theta::Vector{TP} | |
| A::Matrix{Float64} |
This file contains hidden or 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
| describe("getTweets - Server", function () { | |
| var server, fakeData = [ /* ... */ ]; | |
| before(function () { | |
| // Doesn’t work :( It’s JSONP! | |
| server = sinon.fakeServer.create(); | |
| server.respondWith( | |
| "GET", | |
| "https://api.twitter.com/.../elijahmanor.json?count=5", | |
| [200, { "Content-Type": "application/json" }, JSON.stringify(fakeData)] |
This file contains hidden or 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
| heroku config:add BUILDPACK_URL=https://github.com/ToonTimbermont/heroku-buildpack-python |