Skip to content

Commit

Permalink
merge function subtract2d, multiply2d, maximum2d, average2d (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
syt123450 committed Nov 25, 2018
1 parent 387c26a commit 4faf17e
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/merge/Average.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @author syt123450 / https://github.com/syt123450
*/

import { MergedLayer2d } from "../layer/abstract/MergedLayer2d";
import { MergedLayer3d } from "../layer/abstract/MergedLayer3d";

function Average( layerList, config ) {
Expand Down Expand Up @@ -44,6 +45,14 @@ function Average( layerList, config ) {

} else if ( layerList[ 0 ].layerDimension === 2 ) {

return new MergedLayer2d( {

operator: operatorType,
mergedElements: layerList,
userConfig: userConfig

} );

} else if ( layerList[ 0 ].layerDimension === 3 ) {

return new MergedLayer3d( {
Expand Down
9 changes: 9 additions & 0 deletions src/merge/Maximum.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @author syt123450 / https://github.com/syt123450
*/

import { MergedLayer2d } from "../layer/abstract/MergedLayer2d";
import { MergedLayer3d } from "../layer/abstract/MergedLayer3d";

function Maximum( layerList, config ) {
Expand Down Expand Up @@ -44,6 +45,14 @@ function Maximum( layerList, config ) {

} else if ( layerList[ 0 ].layerDimension === 2 ) {

return new MergedLayer2d( {

operator: operatorType,
mergedElements: layerList,
userConfig: userConfig

} );

} else if ( layerList[ 0 ].layerDimension === 3 ) {

return new MergedLayer3d( {
Expand Down
9 changes: 9 additions & 0 deletions src/merge/Multiply.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @author syt123450 / https://github.com/syt123450
*/

import { MergedLayer2d } from "../layer/abstract/MergedLayer2d";
import { MergedLayer3d } from "../layer/abstract/MergedLayer3d";

function Multiply( layerList, config ) {
Expand Down Expand Up @@ -44,6 +45,14 @@ function Multiply( layerList, config ) {

} else if ( layerList[ 0 ].layerDimension === 2 ) {

return new MergedLayer2d( {

operator: operatorType,
mergedElements: layerList,
userConfig: userConfig

} );

} else if ( layerList[ 0 ].layerDimension === 3 ) {

return new MergedLayer3d( {
Expand Down
9 changes: 9 additions & 0 deletions src/merge/Subtract.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @author syt123450 / https://github.com/syt123450
*/

import { MergedLayer2d } from "../layer/abstract/MergedLayer2d";
import { MergedLayer3d } from "../layer/abstract/MergedLayer3d";

function Subtract( layerList, config ) {
Expand Down Expand Up @@ -44,6 +45,14 @@ function Subtract( layerList, config ) {

} else if ( layerList[ 0 ].layerDimension === 2 ) {

return new MergedLayer2d( {

operator: operatorType,
mergedElements: layerList,
userConfig: userConfig

} );

} else if ( layerList[ 0 ].layerDimension === 3 ) {

return new MergedLayer3d( {
Expand Down
30 changes: 29 additions & 1 deletion src/merge/factory/StrategyFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import { Multiply3d } from "../strategy/Multiply3d";
import { Dot3d } from "../strategy/Dot3d";
import { Maximum3d } from "../strategy/Maximum3d";
import { Average3d } from "../strategy/Average3d";
import {Add2d} from "../strategy/Add2d";
import { Add2d } from "../strategy/Add2d";
import { Subtract2d } from "../strategy/Subtract2d";
import { Maximum2d } from "../strategy/Maximum2d";
import { Average2d } from "../strategy/Average2d";
import { Multiply2d } from "../strategy/Multiply2d";

let StrategyFactory = ( function() {

Expand Down Expand Up @@ -53,6 +57,30 @@ let StrategyFactory = ( function() {

return new Add2d( mergedElements );

} else if ( operator === "concatenate" ) {



} else if ( operator === "subtract" ) {

return new Subtract2d( mergedElements );

} else if ( operator === "multiply" ) {

return new Multiply2d( mergedElements );

} else if ( operator === "dot" ) {



} else if ( operator === "maximum" ) {

return new Maximum2d( mergedElements );

} else if ( operator === "average" ) {

return new Average2d( mergedElements );

}

} else if ( dimension === 1 ) {
Expand Down
17 changes: 17 additions & 0 deletions src/merge/strategy/Average2d.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @author syt123450 / https://github.com/syt123450
*/

import { StableMerge2d } from "../abstract/StableMerge2d";

function Average2d( mergedElements ) {

StableMerge2d.call( this, mergedElements );

this.strategyType = "Average2d";

}

Average2d.prototype = Object.assign( Object.create( StableMerge2d.prototype ) );

export { Average2d };
17 changes: 17 additions & 0 deletions src/merge/strategy/Maximum2d.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @author syt123450 / https://github.com/syt123450
*/

import { StableMerge2d } from "../abstract/StableMerge2d";

function Maximum2d( mergedElements ) {

StableMerge2d.call( this, mergedElements );

this.strategyType = "Maximum2d";

}

Maximum2d.prototype = Object.assign( Object.create( StableMerge2d.prototype ) );

export { Maximum2d };
17 changes: 17 additions & 0 deletions src/merge/strategy/Multiply2d.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @author syt123450 / https://github.com/syt123450
*/

import { StableMerge2d } from "../abstract/StableMerge2d";

function Multiply2d( mergedElements ) {

StableMerge2d.call( this, mergedElements );

this.strategyType = "Multiply2d";

}

Multiply2d.prototype = Object.assign( Object.create( StableMerge2d.prototype ) );

export { Multiply2d };
17 changes: 17 additions & 0 deletions src/merge/strategy/Subtract2d.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @author syt123450 / https://github.com/syt123450
*/

import { StableMerge2d } from "../abstract/StableMerge2d";

function Subtract2d( mergedElements ) {

StableMerge2d.call( this, mergedElements );

this.strategyType = "Subtract2d";

}

Subtract2d.prototype = Object.assign( Object.create( StableMerge2d.prototype ) );

export { Subtract2d };
2 changes: 1 addition & 1 deletion test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

model.add( conv1d2 );

let addLayer = TSP.layers.Add( [ conv1d1, conv1d2 ] );
let addLayer = TSP.layers.Multiply( [ conv1d1, conv1d2 ] );

model.add( addLayer );

Expand Down

0 comments on commit 4faf17e

Please sign in to comment.