This gist has been moved to https://github.com/offchan42/machine-learning-curriculum
Please see that repository instead because you can make pull requests there and later updates will be pushed there too.
===
| # | |
| # Copyright 201 Google Inc. All Rights Reserved. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software |
| # | |
| # Copyright 201 Google Inc. All Rights Reserved. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software |
| # Extracted using: $ unzip -p lib/pycharm.jar com/jetbrains/python/PyBundle.properties | grep -B1 INSP.NAME | grep '^#' | sed 's|Inspection||g' | sed -e 's|#\s\{,1\}|# noinspection |' | |
| # noinspection PyPep8 | |
| # noinspection PyPep8Naming | |
| # noinspection PyTypeChecker | |
| # noinspection PyAbstractClass | |
| # noinspection PyArgumentEqualDefault | |
| # noinspection PyArgumentList | |
| # noinspection PyAssignmentToLoopOrWithParameter | |
| # noinspection PyAttributeOutsideInit |
| // Colors reference | |
| // You can use the following as so: | |
| // console.log(colorCode, data); | |
| // console.log(`${colorCode}some colorful text string${resetCode} rest of string in normal color`); | |
| // | |
| // ... and so on. | |
| export const reset = "\x1b[0m" | |
| export const bright = "\x1b[1m" | |
| export const dim = "\x1b[2m" |
| import collections | |
| import gym | |
| import numpy as np | |
| import tensorflow as tf | |
| from gym import wrappers | |
| ENV_ID = 'CartPole-v0' | |
| SAVE_PATH = '/tmp/cartpole-experiment-3' |
===
| '''This script goes along the blog post | |
| "Building powerful image classification models using very little data" | |
| from blog.keras.io. | |
| It uses data that can be downloaded at: | |
| https://www.kaggle.com/c/dogs-vs-cats/data | |
| In our setup, we: | |
| - created a data/ folder | |
| - created train/ and validation/ subfolders inside data/ | |
| - created cats/ and dogs/ subfolders inside train/ and validation/ | |
| - put the cat pictures index 0-999 in data/train/cats |
| """ 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 |
| # A simple cheat sheet of Spark Dataframe syntax | |
| # Current for Spark 1.6.1 | |
| # import statements | |
| from pyspark.sql import SQLContext | |
| from pyspark.sql.types import * | |
| from pyspark.sql.functions import * | |
| #creating dataframes | |
| df = sqlContext.createDataFrame([(1, 4), (2, 5), (3, 6)], ["A", "B"]) # from manual data |
Picking the right architecture = Picking the right battles + Managing trade-offs