mirror of
https://github.com/wassname/keras-js.git
synced 2026-09-10 12:15:12 +08:00
add SpatialDropout2D and SpatialDropout3D for compatibility purposes
This commit is contained in:
@@ -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 {
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user