Skip to content

Commit 6c3c55e

Browse files
use fix for tf.maximum for now in leaky relu
1 parent 4ef65c1 commit 6c3c55e

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/NetInput.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ export class NetInput {
8686
return this._inputSize
8787
}
8888

89+
public get relativePaddings(): Point[] {
90+
return Array(this.inputs.length).fill(0).map(
91+
(_, batchIdx) => this.getRelativePaddings(batchIdx)
92+
)
93+
}
94+
95+
public get reshapedInputDimensions(): Dimensions[] {
96+
return Array(this.inputs.length).fill(0).map(
97+
(_, batchIdx) => this.getReshapedInputDimensions(batchIdx)
98+
)
99+
}
100+
89101
public getInputDimensions(batchIdx: number): number[] {
90102
return this._inputDimensions[batchIdx]
91103
}

src/tinyYolov2/leaky.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as tf from '@tensorflow/tfjs-core';
22

33
export function leaky(x: tf.Tensor4D): tf.Tensor4D {
44
return tf.tidy(() => {
5-
return tf.maximum(x, tf.mul(x, tf.scalar(0.10000000149011612)))
5+
const min = tf.mul(x, tf.scalar(0.10000000149011612))
6+
return tf.add(tf.relu(tf.sub(x, min)), min)
7+
//return tf.maximum(x, min)
68
})
79
}

0 commit comments

Comments
 (0)