mirror of
https://github.com/wassname/keras-js.git
synced 2026-09-10 12:15:12 +08:00
update layer constructors
This commit is contained in:
@@ -9,8 +9,8 @@ export default class ELU extends Layer {
|
||||
* Creates a ELU activation layer
|
||||
* @param {number} alpha - scale for the negative factor
|
||||
*/
|
||||
constructor (alpha = 1.0) {
|
||||
super({})
|
||||
constructor (alpha = 1.0, attrs = {}) {
|
||||
super(attrs)
|
||||
this.alpha = alpha
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ export default class LeakyReLU extends Layer {
|
||||
* Creates a LeakyReLU activation layer
|
||||
* @param {number} alpha - negative slope coefficient
|
||||
*/
|
||||
constructor (alpha = 0.3) {
|
||||
super({})
|
||||
constructor (alpha = 0.3, attrs = {}) {
|
||||
super(attrs)
|
||||
this.alpha = alpha
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ export default class PReLU extends Layer {
|
||||
/**
|
||||
* Creates a PReLU activation layer
|
||||
*/
|
||||
constructor () {
|
||||
super({})
|
||||
constructor (attrs = {}) {
|
||||
super(attrs)
|
||||
|
||||
// Layer weights specification
|
||||
this.params = ['alphas']
|
||||
|
||||
@@ -9,8 +9,8 @@ export default class ParametricSoftplus extends Layer {
|
||||
/**
|
||||
* Creates a ParametricSoftplus activation layer
|
||||
*/
|
||||
constructor () {
|
||||
super({})
|
||||
constructor (attrs = {}) {
|
||||
super(attrs)
|
||||
|
||||
// Layer weights specification
|
||||
this.params = ['alphas', 'betas']
|
||||
|
||||
@@ -9,8 +9,8 @@ export default class SReLU extends Layer {
|
||||
/**
|
||||
* Creates a SReLU activation layer
|
||||
*/
|
||||
constructor () {
|
||||
super({})
|
||||
constructor (attrs = {}) {
|
||||
super(attrs)
|
||||
|
||||
// Layer weights specification
|
||||
this.params = ['t_left', 'a_left', 't_right', 'a_right']
|
||||
|
||||
@@ -9,8 +9,8 @@ export default class ThresholdedReLU extends Layer {
|
||||
* Creates a ThresholdedReLU activation layer
|
||||
* @param {number} theta - float >= 0. Threshold location of activation.
|
||||
*/
|
||||
constructor (theta = 1.0) {
|
||||
super({})
|
||||
constructor (theta = 1.0, attrs = {}) {
|
||||
super(attrs)
|
||||
this.theta = theta
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ export default class Activation extends Layer {
|
||||
* @param {string} activation - name of activation function
|
||||
*/
|
||||
constructor (activation, attrs = {}) {
|
||||
super({})
|
||||
super(attrs)
|
||||
this.activation = activations[activation]
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ export default class Dropout extends Layer {
|
||||
* Creates an Dropout layer
|
||||
* @param {number} p - fraction of the input units to drop (between 0 and 1)
|
||||
*/
|
||||
constructor (p) {
|
||||
super({})
|
||||
constructor (p, attrs = {}) {
|
||||
super(attrs)
|
||||
this.p = Math.min(Math.max(0, p), 1)
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ export default class Flatten extends Layer {
|
||||
/**
|
||||
* Creates a Flatten layer
|
||||
*/
|
||||
constructor () {
|
||||
super({})
|
||||
constructor (attrs = {}) {
|
||||
super(attrs)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,8 +10,8 @@ export default class Permute extends Layer {
|
||||
* Creates a Permute layer
|
||||
* @param {number[]} dims
|
||||
*/
|
||||
constructor (dims) {
|
||||
super({})
|
||||
constructor (dims, attrs = {}) {
|
||||
super(attrs)
|
||||
this.dims = dims.map(dim => dim - 1)
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ export default class RepeatVector extends Layer {
|
||||
* Creates a RepeatVector layer
|
||||
* @param {number} n
|
||||
*/
|
||||
constructor (n) {
|
||||
super({})
|
||||
constructor (n, attrs = {}) {
|
||||
super(attrs)
|
||||
this.n = n
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ export default class Reshape extends Layer {
|
||||
* Creates a Reshape layer
|
||||
* @param {number[]} shape
|
||||
*/
|
||||
constructor (shape) {
|
||||
super({})
|
||||
constructor (shape, attrs = {}) {
|
||||
super(attrs)
|
||||
this.shape = shape
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user