This file contains 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 sparktorch import SparkTorch, serialize_torch_obj | |
from pyspark.sql import SparkSession | |
from pyspark.ml.feature import VectorAssembler | |
from pyspark.sql.functions import rand | |
from pyspark.ml.pipeline import Pipeline | |
import torch | |
import torch.nn as nn | |
spark = SparkSession.builder.appName("examples").master('local[*]').getOrCreate() |
This file contains 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 sparkflow.graph_utils import build_graph | |
from sparkflow.tensorflow_async import SparkAsyncDL | |
import tensorflow as tf | |
from pyspark.ml.feature import VectorAssembler, OneHotEncoder | |
from pyspark.ml.pipeline import Pipeline | |
#simple tensorflow network | |
def small_model(): | |
x = tf.placeholder(tf.float32, shape=[None, 784], name='x') | |
y = tf.placeholder(tf.float32, shape=[None, 10], name='y') |
This file contains 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 tensorflow as tf | |
import numpy as np | |
from google.protobuf import json_format | |
import json | |
np.random.seed(12345) | |
def tensorflow_get_weights(): | |
""" |
This file contains 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 tensorflow as tf | |
import numpy as np | |
from google.protobuf import json_format | |
np.random.seed(12345) | |
def tensorflow_get_weights(): | |
""" | |
@author https://github.com/maxim5 |
This file contains 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 keras.layers.core import Permute | |
from keras.layers import Dense, Activation, RepeatVector, merge,Flatten, TimeDistributed, Input | |
from keras.layers import Embedding, LSTM | |
from keras.models import Model | |
hidden = 225 | |
features = get_features() | |
outputs = get_outputs() |
This file contains 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 keras.models import Sequential | |
from keras.layers import Dense, Activation | |
from keras.layers import LSTM, Masking | |
from keras.optimizers import RMSprop | |
import numpy as np | |
""" | |
This gist shows you have to do a simple seq-to-seq with keras with words instead of chars. | |
It is roughly based on this example https://github.com/fchollet/keras/blob/master/examples/lstm_text_generation.py |
This file contains 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 org.apache.spark.ml.feature.*; | |
class ExampleUsage { | |
public void example(){ | |
List<Row> dubs = Lists.newArrayList( | |
RowFactory.create(1000.0, 1000.0, 1.0), | |
RowFactory.create(90.0, 90.0, 0.0) | |
); | |
DataFrame df = sqlContext.createDataFrame(dubs, createStruct()); |
This file contains 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 com.derek.ml.math.ErrorFunctions; | |
import com.derek.ml.math.Statistics; | |
import com.derek.ml.model.Chromosome; | |
import com.derek.ml.model.LabeledPoint; | |
import com.derek.ml.model.Pair; | |
import java.util.*; | |
import java.util.stream.Collectors; | |
This file contains 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 cdapp.services; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import com.google.common.collect.Lists; | |
import org.apache.spark.SparkConf; | |
import org.apache.spark.api.java.JavaPairRDD; | |
import org.apache.spark.api.java.JavaRDD; | |
import org.apache.spark.api.java.JavaSparkContext; | |
import org.apache.spark.ml.Pipeline; |