add SpatialDropout2D and SpatialDropout3D for compatibility purposes

This commit is contained in:
Leon Chen
2016-09-21 23:58:54 -04:00
parent 6a14d152c5
commit 98e14f6fa0
4 changed files with 76 additions and 1 deletions
+2 -1
View File
@@ -2,7 +2,8 @@ import Layer from '../../Layer'
/**
* Dropout layer class
* Note that this layer is here for compatibility, it's only applied during training time.
* Note that this layer is here only for compatibility purposes,
* as it's only active during training phase.
*/
export default class Dropout extends Layer {
/**
+35
View File
@@ -0,0 +1,35 @@
import Layer from '../../Layer'
/**
* SpatialDropout2D layer class
* Note that this layer is here only for compatibility purposes,
* as it's only active during training phase.
*/
export default class SpatialDropout2D extends Layer {
/**
* Creates an SpatialDropout2D layer
* @param {number} attrs.p - fraction of the input units to drop (between 0 and 1)
* @param {number} [attrs.dimOrdering] - `tf` or `th`
*/
constructor (attrs = {}) {
super(attrs)
this.layerClass = 'SpatialDropout2D'
const {
p = 0.5,
dimOrdering = 'tf'
} = attrs
this.p = Math.min(Math.max(0, p), 1)
this.dimOrdering = dimOrdering
}
/**
* Method for layer computational logic
* @param {Tensor} x
* @returns {Tensor} x
*/
call (x) {
return x
}
}
+35
View File
@@ -0,0 +1,35 @@
import Layer from '../../Layer'
/**
* SpatialDropout3D layer class
* Note that this layer is here only for compatibility purposes,
* as it's only active during training phase.
*/
export default class SpatialDropout3D extends Layer {
/**
* Creates an SpatialDropout3D layer
* @param {number} attrs.p - fraction of the input units to drop (between 0 and 1)
* @param {number} [attrs.dimOrdering] - `tf` or `th`
*/
constructor (attrs = {}) {
super(attrs)
this.layerClass = 'SpatialDropout3D'
const {
p = 0.5,
dimOrdering = 'tf'
} = attrs
this.p = Math.min(Math.max(0, p), 1)
this.dimOrdering = dimOrdering
}
/**
* Method for layer computational logic
* @param {Tensor} x
* @returns {Tensor} x
*/
call (x) {
return x
}
}
+4
View File
@@ -1,6 +1,8 @@
import Dense from './Dense'
import Activation from './Activation'
import Dropout from './Dropout'
import SpatialDropout2D from './SpatialDropout2D'
import SpatialDropout3D from './SpatialDropout3D'
import Flatten from './Flatten'
import Reshape from './Reshape'
import Permute from './Permute'
@@ -13,6 +15,8 @@ export {
Dense,
Activation,
Dropout,
SpatialDropout2D,
SpatialDropout3D,
Flatten,
Reshape,
Permute,