Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mods
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
mods
Commits
65f2b3f8
Commit
65f2b3f8
authored
7 years ago
by
Thrasyvoulos Karydis
Browse files
Options
Downloads
Patches
Plain Diff
first pass on ML bottom up
parent
db10525d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
files.html
+12
-0
12 additions, 0 deletions
files.html
modules/index.html
+3
-0
3 additions, 0 deletions
modules/index.html
modules/ml/fully-connected
+111
-0
111 additions, 0 deletions
modules/ml/fully-connected
modules/ml/nonlinearity
+118
-0
118 additions, 0 deletions
modules/ml/nonlinearity
with
244 additions
and
0 deletions
files.html
+
12
−
0
View file @
65f2b3f8
...
...
@@ -10,10 +10,19 @@
</script>
<i>
.git
</i><br>
<a
href=
'./.gitignore'
>
.gitignore
</a><br>
<i>
.idea
</i><br>
<i>
inspectionProfiles
</i><br>
<a
href=
'./.idea/inspectionProfiles/Project_Default.xml'
>
Project_Default.xml
</a><br>
<a
href=
'./.idea/jsLibraryMappings.xml'
>
jsLibraryMappings.xml
</a><br>
<a
href=
'./.idea/mods.iml'
>
mods.iml
</a><br>
<a
href=
'./.idea/modules.xml'
>
modules.xml
</a><br>
<a
href=
'./.idea/vcs.xml'
>
vcs.xml
</a><br>
<a
href=
'./.idea/workspace.xml'
>
workspace.xml
</a><br>
<a
href=
'./README.md'
>
README.md
</a><br>
<a
href=
'./files.html'
>
files.html
</a><br>
<a
href=
'./index.html'
>
index.html
</a><br>
<i>
js
</i><br>
<a
href=
'./js/convnet-min.js'
>
convnet-min.js
</a><br>
<a
href=
'./js/deviceserver.js'
>
deviceserver.js
</a><br>
<a
href=
'./js/echoserver.js'
>
echoserver.js
</a><br>
<a
href=
'./js/files.js'
>
files.js
</a><br>
...
...
@@ -85,6 +94,9 @@
<a
href=
'./modules/math/scalar'
>
scalar
</a><br>
<i>
mesh
</i><br>
<a
href=
'./modules/mesh/slice'
>
slice
</a><br>
<i>
ml
</i><br>
<a
href=
'./modules/ml/fully-connected'
>
fully-connected
</a><br>
<a
href=
'./modules/ml/nonlinearity'
>
nonlinearity
</a><br>
<i>
object
</i><br>
<a
href=
'./modules/object/download'
>
download
</a><br>
<a
href=
'./modules/object/set'
>
set
</a><br>
...
...
This diff is collapsed.
Click to expand it.
modules/index.html
+
3
−
0
View file @
65f2b3f8
...
...
@@ -67,6 +67,9 @@
<a
href=
"javascript:handler('modules/math/scalar')"
>
scalar
</a><br>
<i>
mesh
</i><br>
<a
href=
"javascript:handler('modules/mesh/slice')"
>
slice
</a><br>
<i>
ml
</i><br>
<a
href=
"javascript:handler('modules/ml/fully-connected')"
>
fully-connected
</a><br>
<a
href=
"javascript:handler('modules/ml/nonlinearity')"
>
nonlinearity
</a><br>
<i>
object
</i><br>
<a
href=
"javascript:handler('modules/object/download')"
>
download
</a><br>
<a
href=
"javascript:handler('modules/object/set')"
>
set
</a><br>
...
...
This diff is collapsed.
Click to expand it.
modules/ml/fully-connected
0 → 100644
+
111
−
0
View file @
65f2b3f8
//
// ML: Fully-Connected module
//
// Thras Karydis
// (c) Massachusetts Institute of Technology 2018
//
// This work may be reproduced, modified, distributed, performed, and
// displayed for any purpose, but must acknowledge the mods
// project. Copyright is retained and must be preserved. The work is
// provided as is; no warranty is provided, and users accept all
// liability.
//
// closure
//
(function(){
//
// module globals
//
var mod = {w: []}
//
// name
//
var name = 'Fully-Connected'
//
// initialization
//
var init = function() {
mod.x = [0.1, 0.7]
mod.w = [0.5, 0.5]
mod.xtext.value = mod.x
mod.wtext.value = mod.w
outputs.y.event()
}
//
// inputs
//
var inputs = {
x:{type:'vector1d',
event:function(evt){
mod.x = evt.detail
mod.xtext.value = mod.x
outputs.y.event()}}}
//
// outputs
//
var outputs = {
y:{type:'number',
event:function(){
var x = mod.x
var w = mod.w
var y = linearSum(x, w)
mod.ytext.value = y
mods.output(mod,'y',y)}}}
//
// interface
//
var interface = function(div){
mod.div = div
div.appendChild(document.createTextNode('x: '))
var input = document.createElement('input')
input.type = 'text'
input.size = 6
input.addEventListener('input',function(evt){
mod.x = parseFloat(mod.xtext.value)
outputs.y.event()
})
div.appendChild(input)
mod.xtext = input
div.appendChild(document.createElement('br'))
div.appendChild(document.createTextNode('w: '))
var input = document.createElement('input')
input.type = 'text'
input.size = 6
input.addEventListener('input',function(evt){
mod.w = parseFloat(mod.wtext.value)
outputs.y.event()
})
div.appendChild(input)
mod.wtext = input
div.appendChild(document.createTextNode('y: '))
var input = document.createElement('input')
input.type = 'text'
input.size = 6
div.appendChild(input)
mod.ytext = input
}
//
// local functions
//
function linearSum(arr1, arr2) {
var sum = 0;
for (var i = 0; i < arr1.length; i++) {
sum += arr1[i] * arr2[i];
}
return sum
}
//
// return values
//
return ({
name:name,
init:init,
inputs:inputs,
outputs:outputs,
interface:interface
})
}())
This diff is collapsed.
Click to expand it.
modules/ml/nonlinearity
0 → 100644
+
118
−
0
View file @
65f2b3f8
//
// ML: Nonlinearity module
//
// Thras Karydis
// (c) Massachusetts Institute of Technology 2018
//
// This work may be reproduced, modified, distributed, performed, and
// displayed for any purpose, but must acknowledge the mods
// project. Copyright is retained and must be preserved. The work is
// provided as is; no warranty is provided, and users accept all
// liability.
//
// closure
//
(function(){
//
// module globals
//
var mod = {functions:{
tanh: tanh,
relu: relu
}}
//
// name
//
var name = 'Nonlinearity'
//
// initialization
//
var init = function() {
mod.x = 123
mod.xtext.value = mod.x
expression = '3*x+0.5'
mod.etext.value = expression
outputs.y.event()
}
//
// inputs
//
var inputs = {
x:{type:'number',
event:function(evt){
mod.x = evt.detail
mod.xtext.value = mod.x
outputs.y.event()}}}
//
// outputs
//
var outputs = {
y:{type:'number',
event:function(){
var x = mod.x
var y = tanh(x) //TODO:change
mod.ytext.value = y
mods.output(mod,'y',y)}}}
//
// interface
//
var interface = function(div){
mod.div = div
div.appendChild(document.createTextNode('x: '))
var input = document.createElement('input')
input.type = 'text'
input.size = 6
input.addEventListener('input',function(evt){
mod.x = parseFloat(mod.xtext.value)
outputs.y.event()
})
div.appendChild(input)
mod.xtext = input
div.appendChild(document.createElement('br'))
div.appendChild(document.createTextNode('expression: '))
var input = document.createElement('SELECT')
input.addEventListener('input',function(evt){
outputs.y.event()
})
input.setAttribute("id", "func-select");
//select menu for functions
for (var property in mod.functions) {
console.log(property)
var z = document.createElement("option");
z.setAttribute("value", property);
var t = document.createTextNode(property);
z.appendChild(t);
input.appendChild(z);
}
div.appendChild(input)
mod.func = input
div.appendChild(document.createElement('br'))
div.appendChild(document.createTextNode('y: '))
var input = document.createElement('input')
input.type = 'text'
input.size = 6
div.appendChild(input)
mod.ytext = input
}
//
// local functions
//
function tanh(x) {
var y = Math.exp(2 * x);
return (y - 1) / (y + 1);
}
function relu(x){
return Math.max(0, x);
}
//
// return values
//
return ({
name:name,
init:init,
inputs:inputs,
outputs:outputs,
interface:interface
})
}())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment