Skip to content

Commit 1dedd20

Browse files
committed
format
1 parent d020f45 commit 1dedd20

File tree

12 files changed

+20
-20
lines changed

12 files changed

+20
-20
lines changed

lib/model/nns/onnx/layer/argmax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default {
2828
const keepdims = new onnx.AttributeProto()
2929
keepdims.setName('keepdims')
3030
keepdims.setType(onnx.AttributeProto.AttributeType.INT)
31-
keepdims.setI(obj.keepdims ?? true ? 1 : 0)
31+
keepdims.setI((obj.keepdims ?? true) ? 1 : 0)
3232
node.addAttribute(keepdims)
3333

3434
graph.addNode(node)

lib/model/nns/onnx/layer/argmin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default {
2828
const keepdims = new onnx.AttributeProto()
2929
keepdims.setName('keepdims')
3030
keepdims.setType(onnx.AttributeProto.AttributeType.INT)
31-
keepdims.setI(obj.keepdims ?? true ? 1 : 0)
31+
keepdims.setI((obj.keepdims ?? true) ? 1 : 0)
3232
node.addAttribute(keepdims)
3333

3434
graph.addNode(node)

lib/model/nns/onnx/layer/mean.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default {
2020
node.addInput(input)
2121
node.addOutput(obj.name)
2222

23-
const keepdims = obj.keepdims ?? true ? 1 : 0
23+
const keepdims = (obj.keepdims ?? true) ? 1 : 0
2424
const attrKeepdims = new onnx.AttributeProto()
2525
attrKeepdims.setName('keepdims')
2626
attrKeepdims.setType(onnx.AttributeProto.AttributeType.INT)

lib/model/nns/onnx/layer/prod.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default {
2020
node.addInput(input)
2121
node.addOutput(obj.name)
2222

23-
const keepdims = obj.keepdims ?? true ? 1 : 0
23+
const keepdims = (obj.keepdims ?? true) ? 1 : 0
2424
const attrKeepdims = new onnx.AttributeProto()
2525
attrKeepdims.setName('keepdims')
2626
attrKeepdims.setType(onnx.AttributeProto.AttributeType.INT)

lib/model/nns/onnx/layer/reduce_max.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default {
2020
node.addInput(input)
2121
node.addOutput(obj.name)
2222

23-
const keepdims = obj.keepdims ?? true ? 1 : 0
23+
const keepdims = (obj.keepdims ?? true) ? 1 : 0
2424
const attrKeepdims = new onnx.AttributeProto()
2525
attrKeepdims.setName('keepdims')
2626
attrKeepdims.setType(onnx.AttributeProto.AttributeType.INT)

lib/model/nns/onnx/layer/reduce_min.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default {
2020
node.addInput(input)
2121
node.addOutput(obj.name)
2222

23-
const keepdims = obj.keepdims ?? true ? 1 : 0
23+
const keepdims = (obj.keepdims ?? true) ? 1 : 0
2424
const attrKeepdims = new onnx.AttributeProto()
2525
attrKeepdims.setName('keepdims')
2626
attrKeepdims.setType(onnx.AttributeProto.AttributeType.INT)

lib/model/nns/onnx/layer/std.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default {
4343
node_variance.addInput(obj.name + '_mul')
4444
node_variance.addOutput(obj.name + '_var')
4545

46-
const keepdims = obj.keepdims ?? true ? 1 : 0
46+
const keepdims = (obj.keepdims ?? true) ? 1 : 0
4747
const attrKeepdims2 = new onnx.AttributeProto()
4848
attrKeepdims2.setName('keepdims')
4949
attrKeepdims2.setType(onnx.AttributeProto.AttributeType.INT)

lib/model/nns/onnx/layer/sum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default {
2020
node.addInput(input)
2121
node.addOutput(obj.name)
2222

23-
const keepdims = obj.keepdims ?? true ? 1 : 0
23+
const keepdims = (obj.keepdims ?? true) ? 1 : 0
2424
const attrKeepdims = new onnx.AttributeProto()
2525
attrKeepdims.setName('keepdims')
2626
attrKeepdims.setType(onnx.AttributeProto.AttributeType.INT)

lib/model/nns/onnx/layer/variance.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default {
4343
node_variance.addInput(obj.name + '_mul')
4444
node_variance.addOutput(obj.name)
4545

46-
const keepdims = obj.keepdims ?? true ? 1 : 0
46+
const keepdims = (obj.keepdims ?? true) ? 1 : 0
4747
const attrKeepdims2 = new onnx.AttributeProto()
4848
attrKeepdims2.setName('keepdims')
4949
attrKeepdims2.setType(onnx.AttributeProto.AttributeType.INT)

tests/lib/model/nns/layer/isigmoid.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe.each([{}, { a: 2, alpha: 2 }])('layer %p', opt => {
6464
for (let j = 0; j < x.cols; j++) {
6565
expect(bi.at(i, j)).toBeCloseTo(
6666
x.at(i, j) >= (opt.a ?? 1) || x.at(i, j) <= -(opt.a ?? 1)
67-
? opt.alpha ?? 1
67+
? (opt.alpha ?? 1)
6868
: y.at(i, j) * (1 - y.at(i, j))
6969
)
7070
}
@@ -84,7 +84,7 @@ describe.each([{}, { a: 2, alpha: 2 }])('layer %p', opt => {
8484
for (let k = 0; k < x.sizes[2]; k++) {
8585
expect(bi.at(i, j, k)).toBeCloseTo(
8686
x.at(i, j, k) >= (opt.a ?? 1) || x.at(i, j, k) <= -(opt.a ?? 1)
87-
? opt.alpha ?? 1
87+
? (opt.alpha ?? 1)
8888
: y.at(i, j, k) * (1 - y.at(i, j, k))
8989
)
9090
}

tests/lib/model/nns/layer/ptanh.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe.each([undefined, 0.1])('layer %p', a => {
1818
const y = layer.calc(x)
1919
for (let i = 0; i < x.rows; i++) {
2020
for (let j = 0; j < x.cols; j++) {
21-
expect(y.at(i, j)).toBeCloseTo(Math.tanh(x.at(i, j)) * (x.at(i, j) < 0 ? a ?? 0.25 : 1))
21+
expect(y.at(i, j)).toBeCloseTo(Math.tanh(x.at(i, j)) * (x.at(i, j) < 0 ? (a ?? 0.25) : 1))
2222
}
2323
}
2424
})
@@ -32,7 +32,7 @@ describe.each([undefined, 0.1])('layer %p', a => {
3232
for (let j = 0; j < x.sizes[1]; j++) {
3333
for (let k = 0; k < x.sizes[2]; k++) {
3434
expect(y.at(i, j, k)).toBeCloseTo(
35-
Math.tanh(x.at(i, j, k)) * (x.at(i, j, k) < 0 ? a ?? 0.25 : 1)
35+
Math.tanh(x.at(i, j, k)) * (x.at(i, j, k) < 0 ? (a ?? 0.25) : 1)
3636
)
3737
}
3838
}
@@ -51,7 +51,7 @@ describe.each([undefined, 0.1])('layer %p', a => {
5151
const bi = layer.grad(bo)
5252
for (let i = 0; i < x.rows; i++) {
5353
for (let j = 0; j < x.cols; j++) {
54-
expect(bi.at(i, j)).toBeCloseTo((1 - y.at(i, j) ** 2) * (x.at(i, j) < 0 ? a ?? 0.25 : 1))
54+
expect(bi.at(i, j)).toBeCloseTo((1 - y.at(i, j) ** 2) * (x.at(i, j) < 0 ? (a ?? 0.25) : 1))
5555
}
5656
}
5757
})
@@ -68,7 +68,7 @@ describe.each([undefined, 0.1])('layer %p', a => {
6868
for (let j = 0; j < x.sizes[1]; j++) {
6969
for (let k = 0; k < x.sizes[2]; k++) {
7070
expect(bi.at(i, j, k)).toBeCloseTo(
71-
(1 - y.at(i, j, k) ** 2) * (x.at(i, j, k) < 0 ? a ?? 0.25 : 1)
71+
(1 - y.at(i, j, k) ** 2) * (x.at(i, j, k) < 0 ? (a ?? 0.25) : 1)
7272
)
7373
}
7474
}
@@ -97,7 +97,7 @@ describe.each([undefined, 0.1])('nn %p', a => {
9797
const y = net.calc(x)
9898
for (let i = 0; i < x.rows; i++) {
9999
for (let j = 0; j < x.cols; j++) {
100-
expect(y.at(i, j)).toBeCloseTo(Math.tanh(x.at(i, j)) * (x.at(i, j) < 0 ? a ?? 0.25 : 1))
100+
expect(y.at(i, j)).toBeCloseTo(Math.tanh(x.at(i, j)) * (x.at(i, j) < 0 ? (a ?? 0.25) : 1))
101101
}
102102
}
103103
})

tests/lib/model/nns/layer/std.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ describe('layer', () => {
246246
for (let i = 0; i < x.rows; i++) {
247247
for (let j = 0; j < x.cols; j++) {
248248
expect(bi.at(i, j)).toBeCloseTo(
249-
(x.at(i, j) - m.at(0, j)) / ((keepdims ?? true ? y.at(0, j) : y.at(j)) * 100)
249+
(x.at(i, j) - m.at(0, j)) / (((keepdims ?? true) ? y.at(0, j) : y.at(j)) * 100)
250250
)
251251
}
252252
}
@@ -269,7 +269,7 @@ describe('layer', () => {
269269
for (let i = 0; i < x.rows; i++) {
270270
for (let j = 0; j < x.cols; j++) {
271271
expect(bi.at(i, j)).toBeCloseTo(
272-
(x.at(i, j) - m.at(i, 0)) / ((keepdims ?? true ? y.at(i, 0) : y.at(i)) * 10)
272+
(x.at(i, j) - m.at(i, 0)) / (((keepdims ?? true) ? y.at(i, 0) : y.at(i)) * 10)
273273
)
274274
}
275275
}
@@ -320,7 +320,7 @@ describe('layer', () => {
320320
for (let k = 0; k < x.sizes[2]; k++) {
321321
expect(bi.at(i, j, k)).toBeCloseTo(
322322
(x.at(i, j, k) - m.at(j, k)) /
323-
((keepdims ?? true ? y.at(0, j, k) : y.at(j, k)) * 15)
323+
(((keepdims ?? true) ? y.at(0, j, k) : y.at(j, k)) * 15)
324324
)
325325
}
326326
}
@@ -347,7 +347,7 @@ describe('layer', () => {
347347
for (let k = 0; k < x.sizes[2]; k++) {
348348
expect(bi.at(i, j, k)).toBeCloseTo(
349349
(x.at(i, j, k) - m.at(i, k)) /
350-
((keepdims ?? true ? y.at(i, 0, k) : y.at(i, k)) * 10)
350+
(((keepdims ?? true) ? y.at(i, 0, k) : y.at(i, k)) * 10)
351351
)
352352
}
353353
}

0 commit comments

Comments
 (0)