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
| ''' | |
| Copyright (c) <2012> Tarek Galal <[email protected]> | |
| 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 furnished to do so, subject to the following | |
| conditions: |
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
| ;; ; made this macro scraching my head between the simplicity of Haskell for fix | |
| ;; ; and the absence of curryfication in Clojure. | |
| ;; (P expr-fn) ; makes expr-fn lazy | |
| ;; (P P expr-fn) ; curry one time expr-fn | |
| ;; (P P P expr-fn) ; curry two time expr-fn | |
| ;; (= ((((P P P str) "a") "b") "c") "abc") ;=> true | |
| (defmacro P [& f] | |
| (let [x (gensym 'x)] ;; cannot be replaced by x# due to nested macro expansion. |
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
| check process hhvm with pidfile /var/run/hhvm/pid | |
| group hhvm | |
| start program = "/usr/sbin/service hhvm start" with timeout 60 seconds | |
| stop program = "/usr/sbin/service hhvm stop" | |
| if failed unixsocket /var/run/hhvm/hhvm.sock then restart | |
| if mem > 400.0 MB for 1 cycles then restart | |
| if 5 restarts with 5 cycles then timeout |
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 | |
| import sys | |
| import scipy.stats as stats | |
| import matplotlib.pyplot as plotter | |
| from gensim import corpora, models, similarities, matutils | |
| # Defines dictionary from the specified corpus. | |
| dictionary = corpora.Dictionary( | |
| line.lower().split() for line in open('corpus_train.txt', 'rb') |
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 pandas as pd | |
| from random import random | |
| flow = (list(range(1,10,1)) + list(range(10,1,-1)))*100 | |
| pdata = pd.DataFrame({"a":flow, "b":flow}) | |
| pdata.b = pdata.b.shift(9) | |
| data = pdata.iloc[10:] * random() # some noise | |
| import numpy as np |
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 | |
| # see http://matpalm.com/blog/2015/03/28/theano_word_embeddings/ | |
| import theano | |
| import theano.tensor as T | |
| import numpy as np | |
| import random | |
| E = np.asarray(np.random.randn(6, 2), dtype='float32') | |
| t_E = theano.shared(E) | |
| t_idxs = T.ivector() |
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
| # Time series forecasting based on multiple time series, including the original one | |
| # This script is based on the following examples and discussions: | |
| # https://gist.github.com/lukovkin/1aefa4509e066690b892 | |
| # https://groups.google.com/forum/#!topic/keras-users/9GsDwkSdqBg | |
| import numpy as np | |
| import pandas as pd | |
| import matplotlib.pyplot as plt | |
| import random | |
| import theano |
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
| '''Functional Keras is a more functional replacement for the Graph API. | |
| ''' | |
| ################### | |
| # 2 LSTM branches # | |
| ################### | |
| a = Input(input_shape=(10, 32)) # output is a TF/TH placeholder, augmented with Keras attributes | |
| b = Input(input_shape=(10, 32)) | |
| encoded_a = LSTM(32)(a) # output is a TF/TH tensor | |
| encoded_b = LSTM(32)(b) |
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 | |
| __author__ = 'Fariz Rahman' | |
| def eq(x, y): | |
| return x.lower().replace(" ", "") == y.lower().replace(" ", "") | |
| def get_words(x): | |
| x = x.replace(" ", " ") |