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
| class Model: | |
| def __init__(self, data, target): | |
| self.data = data | |
| self.target = target | |
| self.prediction | |
| self.optimize | |
| self.error | |
| @lazy_property |
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 functools | |
| def lazy_property(function): | |
| attribute = '_cache_' + function.__name__ | |
| @property | |
| @functools.wraps(function) | |
| def decorator(self): | |
| if not hasattr(self, attribute): | |
| setattr(self, attribute, function(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
| class Model: | |
| def __init__(self, data, target): | |
| self.data = data | |
| self.target = target | |
| self._prediction = None | |
| self._optimize = None | |
| self._error = None | |
| @property |
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
| class Model: | |
| def __init__(self, data, target): | |
| data_size = int(data.get_shape()[1]) | |
| target_size = int(target.get_shape()[1]) | |
| weight = tf.Variable(tf.truncated_normal([data_size, target_size])) | |
| bias = tf.Variable(tf.constant(0.1, shape=[target_size])) | |
| incoming = tf.matmul(data, weight) + bias | |
| self._prediction = tf.nn.softmax(incoming) | |
| cross_entropy = -tf.reduce_sum(target, tf.log(self._prediction)) |
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
| class array(object) : | |
| """Simple Array object that support autodiff.""" | |
| def __init__(self, value, name=None): | |
| self.value = value | |
| if name: | |
| self.grad = lambda g : {name : g} | |
| def __add__(self, other): | |
| assert isinstance(other, int) | |
| ret = array(self.value + other) |
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
| " Don't try to be vi compatible | |
| set nocompatible | |
| " Helps force plugins to load correctly when it is turned back on below | |
| filetype off | |
| " Load plugins here (pathogen or vundle) | |
| set rtp+=~/.vim/bundle/Vundle.vim | |
| call vundle#begin() | |
| Plugin 'VundleVim/Vundle.vim' |
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 pyspark.sql import SparkSession | |
| from pyspark.sql.functions import * | |
| from pyspark.sql.types import * | |
| from pyspark.ml.feature import StringIndexer | |
| def preprocess_age(age): | |
| if age > 70 or age < 5: | |
| return -1 | |
| 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
| # Default system properties included when running spark-submit. | |
| # This is useful for setting default environmental settings. | |
| # Example: | |
| # spark.master spark://master:7077 | |
| spark.eventLog.enabled true | |
| spark.eventLog.dir file:///home/ozawa/sparkeventlogs | |
| # spark.serializer org.apache.spark.serializer.KryoSerializer | |
| # spark.driver.memory 5g | |
| # spark.executor.extraJavaOptions -XX:+PrintGCDetails -Dkey=value -Dnumbers="one two three" |
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 flask import Flask | |
| app = Flask(__name__) | |
| @app.route('/') | |
| def hello_world(): | |
| return 'Hello, world!' | |
| if __name__ == '__main__': | |
| app.run(debug=True,host='0.0.0.0') |
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
| //package org.myorg; | |
| import java.io.IOException; | |
| import java.util.*; | |
| import org.apache.hadoop.fs.Path; | |
| import org.apache.hadoop.conf.*; | |
| import org.apache.hadoop.io.*; | |
| import org.apache.hadoop.mapred.*; | |
| import org.apache.hadoop.util.*; |