Coder Social home page Coder Social logo

gameofthrow / sparkdl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jeremynixon/sparkdl

0.0 1.0 0.0 25 KB

MLlib Convolutional and Feedforward Neural Network implementation with a high level API and advanced optimizers.

License: Apache License 2.0

Scala 100.00%

sparkdl's Introduction

Deep Learning for Spark MLlib

Distributed deep learning on Spark. Keras-like API and integration. Spark Package homepage.

Convolutional Neural Network

import org.apache.spark.ml.dl._
import org.apache.spark.sql.SQLContext

val sqlContext = new SQLContext(sc)
val data = sqlContext.read.format("libsvm").load("path_to_dataset.txt")
val dataset = data.withColumnRenamed("label", "labels")

# Set up architecture for convolutional neural network 
val model = new Sequential()
model.add(new Convolution2D(8, 1, 3, 3, 28, 28))
model.add(new Activation("relu"))
model.add(new Dropout(0.5))
model.add(new Dense(6272, 10))
model.add(new Activation("softmax"))

model.compile(loss="categorical_crossentropy",
 optimizer=new Optimizer().adam(lr=.001),
 metrics="Accuracy")

val trained = model.fit(dataset, num_iters=500)

Feedforward Neural Network


import org.apache.spark.ml.dl._
import org.apache.spark.sql.SQLContext

val sqlContext = new SQLContext(sc)
val data = sqlContext.read.format("libsvm").load("path_to_dataset.txt")
val dataset = data.withColumnRenamed("label", "labels")

# Set up architecture for feedforward neural network
val model = new Sequential()
model.add(new Dense(784, 100))
model.add(new Activation("relu"))
model.add(new Dense(100, 10))
model.add(new Activation("softmax"))

model.compile(loss="categorical_crossentropy",
 optimizer=new Optimizer().adam(lr=.001),
 metrics="Accuracy")

val trained = model.fit(dataset, num_iters=500)

Installation Options

Spark Packages

Clone and Build

Clone the project with:

git clone https://github.com/JeremyNixon/sparkdl.git

cd into the repository and run

sbt assembly

to build the project.

Next we need to publish locally to ivy or to maven. To publish to ivy, run

sbt publish-local

or to publish to maven, run

sbt publishM2

and call spark with

./spark-shell --packages default:sparkdl_2.11:0.0.1

to run spark with sparkdl.

Contribution Guide

To contribute to the project, you'll need to build and modify your cloned fork of the project.

Once you've made your changes, run:

sbt assembly

to build. Then you'll need to publish to your local maven or ivy with a different version number. Modify the version number in pom.xml and in build.sbt, for example from 1.0.0 to 1.0.1. Then call:

sbt publish-local
# sbt publishM2 to publish to maven will also work, resulting in a different name.

To publish to ivy. Once your local copy has been published, you can call it from spark packages. This call will be different from the original call - your scala version will be appended to the name and the root of the call will now be default. The version number will also change to the version you've provided. For example:

./spark-shell --packages default:sparkdl_2.11:0.0.1

Where you can run your modified code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.