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 | |
| import matplotlib.pyplot as plt | |
| x = np.arange(-10, 10, 0.01) | |
| alpha = 1.6733 | |
| l = 1.0507 | |
| y = l*((x > 0)*x + (x <= 0)*(alpha * np.exp(x) - alpha)) | |
| plt.rc('text', usetex=True) | |
| plt.rc('font', family='serif') |
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
| """ Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """ | |
| import numpy as np | |
| import cPickle as pickle | |
| import gym | |
| # hyperparameters | |
| H = 200 # number of hidden layer neurons | |
| batch_size = 10 # every how many episodes to do a param update? | |
| learning_rate = 1e-4 | |
| gamma = 0.99 # discount factor for reward |
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_redis_uri(): | |
| if 'VCAP_SERVICES' not in os.environ: | |
| return os.getenv('REDIS_HOST', ''), int(os.getenv('REDIS_PORT', '6379')), os.getenv('REDIS_PASSWORD', '') | |
| services = json.loads(os.getenv('VCAP_SERVICES')) | |
| if 'redis' not in services: | |
| # when redis isn't available. | |
| return '', 0, '' | |
| redis_env = services['redis'][0]['credentials'] |
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
| from __future__ import print_function | |
| from __future__ import unicode_literals | |
| from multiprocessing import Process, Queue | |
| import six | |
| import numpy as np | |
| import tensorflow as tf | |
| import arimo |
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
| 46647746 [qtp243803905-157] WARN org.eclipse.jetty.servlet.ServletHandler - Error for /command/DropNA | |
| java.lang.StackOverflowError | |
| at org.apache.spark.sql.hive.HiveQl$.nodeToExpr(HiveQl.scala:1528) | |
| at org.apache.spark.sql.hive.HiveQl$.nodeToExpr(HiveQl.scala:1427) | |
| at org.apache.spark.sql.hive.HiveQl$.nodeToExpr(HiveQl.scala:1427) | |
| at org.apache.spark.sql.hive.HiveQl$.nodeToExpr(HiveQl.scala:1427) | |
| at org.apache.spark.sql.hive.HiveQl$.nodeToExpr(HiveQl.scala:1427) | |
| at org.apache.spark.sql.hive.HiveQl$.nodeToExpr(HiveQl.scala:1427) | |
| at org.apache.spark.sql.hive.HiveQl$.nodeToExpr(HiveQl.scala:1427) | |
| at org.apache.spark.sql.hive.HiveQl$.nodeToExpr(HiveQl.scala:1427) |
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 co_dumps(f): | |
| import base64, cPickle | |
| co = f.func_code | |
| ss = [[co.co_argcount,co.co_nlocals, co.co_stacksize,co.co_flags, | |
| co.co_code,co.co_consts,co.co_names,co.co_varnames,co.co_filename, | |
| co.co_name,co.co_firstlineno,co.co_lnotab], None, f.func_name, f.func_defaults, f.func_closure] | |
| return base64.urlsafe_b64encode(cPickle.dumps(ss)) | |
| def ch(x): | |
| if x > 10: |
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
| $ CLASSPATH=/Users/vupham/lib/jython/jython-standalone-2.7.0.jar scala | |
| Welcome to Scala version 2.10.5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_79). | |
| Type in expressions to have them evaluated. | |
| Type :help for more information. | |
| scala> import org.python.core._ | |
| import org.python.core._ | |
| scala> import org.python.util.PythonInterpreter | |
| import org.python.util.PythonInterpreter |
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
| In [1]: import cPickle, types, base64, new | |
| In [2]: code_string = 'KGxwMQoobHAyCkkxCmFJMQphSTIKYUk2NwphUyd8XHgwMFx4MDBkXHgwMVx4MDBrXHgwNFx4MDByXHgxMFx4MDBkXHgwMlx4MDBTZFx4MDNceDAwUycKcDMKYShOSTEwCkkxCkkwCnRwNAphKHRhKFMneCcKdHA1CmFTJzxpcHl0aG9uLWlucHV0LTIxLTZkNGIyMjljNDhkMD4nCnA2CmFTJ2NoJwpwNwphSTEKYVMnXHgwMFx4MDFceDBjXHgwMVx4MDRceDAxJwpwOAphYU5hZzcKYU5hTmEu' | |
| In [3]: def load_code(code_string): | |
| ...: rr = cPickle.loads(base64.urlsafe_b64decode(code_string)) | |
| ...: r = rr[0] | |
| ...: return types.FunctionType(new.code(r[0],r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8],r[9],r[10],r[11]), globals(), rr[2], rr[3], rr[4]) | |
| ...: |