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
| #!/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
| """ | |
| 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
| 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
| '''This scripts implements Kim's paper "Convolutional Neural Networks for Sentence Classification" | |
| with a very small embedding size (20) than the commonly used values (100 - 300) as it gives better | |
| result with much less parameters. | |
| Run on GPU: THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python imdb_cnn.py | |
| Get to 0.853 test accuracy after 5 epochs. 13s/epoch on Nvidia GTX980 GPU. | |
| ''' | |
| from __future__ import print_function |
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/env python | |
| # coding: utf-8 | |
| """Sampling Sequence Data from model""" | |
| import numpy as np | |
| import tensorflow as tf | |
| import json | |
| import cPickle as pickle | |
| import itertools as it | |
| from rnnlib import PTBModel |
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
| def get_H_n(X): | |
| return X[:, -1, :] # get last element from time dim | |
| def get_Y(X): | |
| return X[:, :110, :] # get first xmaxlen elem from time dim | |
| def get_R(X): | |
| Y, alpha = X.values() # Y should be (L,k) and alpha should be (L,) and ans should be (k,) |
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
| """ | |
| Possibly correct implementation of an all conv neural network using a single residual module | |
| This code was written for instruction purposes and no attempt to get the best results were made. | |
| References: | |
| Deep Residual Learning for Image Recognition: http://arxiv.org/pdf/1512.03385v1.pdf | |
| STRIVING FOR SIMPLICITY, THE ALL CONVOLUTIONAL NET: http://arxiv.org/pdf/1412.6806v3.pdf | |
| A video walking through the code and main ideas: https://youtu.be/-N_zlfKo4Ec |
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
| # Example for my blog post at: | |
| # http://danijar.com/introduction-to-recurrent-networks-in-tensorflow/ | |
| import functools | |
| import sets | |
| import tensorflow as tf | |
| def lazy_property(function): | |
| attribute = '_' + function.__name__ |
- act2vec, trace2vec, log2vec, model2vec https://link.springer.com/chapter/10.1007/978-3-319-98648-7_18
- apk2vec https://arxiv.org/abs/1809.05693
- app2vec http://paul.rutgers.edu/~qma/research/ma_app2vec.pdf
- ast2vec https://arxiv.org/abs/2103.11614
- attribute2vec https://arxiv.org/abs/2004.01375
- author2vec http://dl.acm.org/citation.cfm?id=2889382
- baller2vec https://arxiv.org/abs/2102.03291
- bb2vec https://arxiv.org/abs/1809.09621