We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5794028 commit d0bfa88Copy full SHA for d0bfa88
tfjs-converter/python/tensorflowjs/op_list/convolution.json
@@ -394,7 +394,8 @@
394
{
395
"tfName": "leakyrelu_alpha",
396
"name": "leakyreluAlpha",
397
- "type": "number"
+ "type": "number",
398
+ "defaultValue": 0.2
399
}
400
]
401
},
@@ -685,4 +686,4 @@
685
686
687
688
-]
689
+]
tfjs-converter/python/tensorflowjs/op_list/matrices.json
@@ -50,6 +50,12 @@
50
"type": "bool",
51
"defaultValue": false
52
53
+ {
54
+ "tfName": "leakyrelu_alpha",
55
+ "name": "leakyreluAlpha",
56
57
58
+ },
59
60
"tfName": "T",
61
"name": "dtype",
@@ -220,4 +226,4 @@
220
226
221
227
222
228
223
229
tfjs-converter/src/operations/executors/matrices_executor_test.ts
@@ -18,12 +18,13 @@
18
import {Tensor} from '@tensorflow/tfjs-core';
19
// tslint:disable-next-line: no-imports-from-dist
20
import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter';
21
+import * as matrices from '../op_list/matrices';
22
23
import {ExecutionContext} from '../../executor/execution_context';
24
import {Node} from '../types';
25
26
import {executeOp} from './matrices_executor';
-import {createBoolAttr, createNumberAttr, createNumericArrayAttr, createStrArrayAttr, createStrAttr, createTensorAttr, createTensorsAttr} from './test_helper';
27
+import {createBoolAttr, createNumberAttr, createNumericArrayAttr, createStrArrayAttr, createStrAttr, createTensorAttr, createTensorsAttr, validateParam} from './test_helper';
28
29
describe('matrices', () => {
30
let node: Node;
@@ -130,6 +131,18 @@ describe('matrices', () => {
130
131
leakyreluAlpha: 0.3
132
});
133
134
+ it('should match json def.', () => {
135
+ node.op = '_FusedMatMul';
136
+
137
+ node.attrParams['fusedOps'] =
138
+ createStrArrayAttr(['biasadd', 'leakyrelu']);
139
+ node.attrParams['numArgs'] = createNumberAttr(1);
140
+ node.attrParams.transposeA = createBoolAttr(true);
141
+ node.attrParams.transposeB = createBoolAttr(false);
142
+ node.attrParams.leakyreluAlpha = createNumberAttr(0.3);
143
144
+ expect(validateParam(node, matrices.json)).toBeTruthy();
145
+ });
146
147
describe('BatchMatMul', () => {
148
it('should call tfOps.matMul', () => {
tfjs-core/src/ops/fused/fused_mat_mul_test.ts
@@ -111,6 +111,26 @@ describeWithFlags('fused matmul', ALL_ENVS, () => {
111
expectArraysClose(await c.data(), [0, 8, -0.9000000357627869, 20]);
112
113
114
+ it('fused A x B with leakyrelu not provided.', async () => {
115
+ const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]);
116
+ const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]);
117
+ const transposeA = false;
118
+ const transposeB = false;
119
120
+ const c = tf.fused.matMul({
121
+ a,
122
+ b,
123
+ transposeA,
124
+ transposeB,
125
+ bias: null,
126
+ activation: 'leakyrelu'
127
128
129
+ expect(c.shape).toEqual([2, 2]);
+ // leakyRelu should use default alpha=0.2.
+ expectArraysClose(await c.data(), [0, 8, -0.6000000238418579, 20]);
it('fused A x B with sigmoid', async () => {
const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]);
const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]);
tfjs-core/src/ops/fused/mat_mul.ts
@@ -63,7 +63,7 @@ function fusedMatMul_({
63
bias,
64
activation = 'linear',
65
preluActivationWeights,
66
- leakyreluAlpha,
+ leakyreluAlpha = 0.2,
67
}: {
68
a: Tensor|TensorLike,
69
b: Tensor|TensorLike,
0 commit comments