Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basic demo added #67

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory" : "demo/bower_components"
}
45 changes: 45 additions & 0 deletions Gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var browserSync = require('browser-sync');
const reload = browserSync.reload;
gulp.task('copy', () =>
gulp.src([
'build/**/*'
], {
base: './'
}).pipe(gulp.dest('demo'))
);
// jshint files
gulp.task('jshint', function () {
//gulp.src(['test/**/*.js'])
// .pipe(jshint())
// .pipe(jshint.reporter());
});
// start local http server for development
gulp.task('http-server', function () {
browserSync({
notify: false,
// Customize the Browsersync console logging prefix
logPrefix: 'WSK',
// Allow scroll syncing across breakpoints
scrollElementMapping: ['main', '.mdl-layout'],
// Run as an https by uncommenting 'https: true'
// Note: this uses an unsigned certificate which on first access
// will present a certificate warning in the browser.
// https: true,
server: ['.tmp', 'demo'],
port: 3000
});
gulp.watch(['demo/**/*'], reload);
});
// start local http server with watch and livereload set up
gulp.task('server', function () {
gulp.run('http-server');
});
gulp.task('default', function () {
gulp.run('jshint', 'copy', 'server');
});
gulp.task('serve', function () {
gulp.run('default');
});

5 changes: 4 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@
"bower_components",
"test",
"tests"
]
],
"dependencies": {
"codemirror": "^5.15.2"
}
}
29 changes: 29 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="egdiv"></div>
<script src="build/convnet.js"></script>
<script>var layer_defs = [];
layer_defs.push({type: 'input', out_sx: 1, out_sy: 1, out_depth: 2});
layer_defs.push({type: 'fc', num_neurons: 5, activation: 'sigmoid'});
layer_defs.push({type: 'regression', num_neurons: 1});
var net = new convnetjs.Net();
net.makeLayers(layer_defs);
var x = new convnetjs.Vol([0.5, -1.3]);
// train on this datapoint, saying [0.5, -1.3] should map to value 0.7:
// note that in this case we are passing it a list, because in general
// we may want to  regress multiple outputs and in this special case we
// used num_neurons:1 for the regression to only regress one.
var trainer = new convnetjs.SGDTrainer(net,
{learning_rate: 0.01, momentum: 0.0, batch_size: 1, l2_decay: 0.001});
trainer.train(x, [0.7]);
// evaluate on a datapoint. We will get a 1x1x1 Vol back, so we get the
// actual output by looking into its 'w' field:
var predicted_values = net.forward(x);
console.log('predicted value: ' + predicted_values.w[0]);</script>
</body>
</html>
Loading