mirror of
https://github.com/socathie/circomlib-ml.git
synced 2026-01-10 06:28:08 -05:00
Add MaxPooling2Dsame and MaxPooling2Dsame_stride test circuits and their dependencies
This commit is contained in:
37
test/MaxPooling2Dsame.js
Normal file
37
test/MaxPooling2Dsame.js
Normal file
@@ -0,0 +1,37 @@
|
||||
const chai = require("chai");
|
||||
const path = require("path");
|
||||
|
||||
const wasm_tester = require("circom_tester").wasm;
|
||||
|
||||
const F1Field = require("ffjavascript").F1Field;
|
||||
const Scalar = require("ffjavascript").Scalar;
|
||||
exports.p = Scalar.fromString("21888242871839275222246405745257275088548364400416034343698204186575808495617");
|
||||
const Fr = new F1Field(exports.p);
|
||||
|
||||
const assert = chai.assert;
|
||||
|
||||
describe("MaxPooling2Dsame layer test", function () {
|
||||
this.timeout(100000000);
|
||||
|
||||
// MaxPooling with strides==poolSize
|
||||
it("(5,5,3) -> (3,3,3)", async () => {
|
||||
const INPUT = require("../models/maxPooling2Dsame_input.json");
|
||||
|
||||
const circuit = await wasm_tester(path.join(__dirname, "circuits", "MaxPooling2Dsame_test.circom"));
|
||||
|
||||
const witness = await circuit.calculateWitness(INPUT, true);
|
||||
|
||||
assert(Fr.eq(Fr.e(witness[0]),Fr.e(1)));
|
||||
});
|
||||
|
||||
// MaxPooling with strides!=poolSize
|
||||
it("(10,10,3) -> (4,4,3)", async () => {
|
||||
const INPUT = require("../models/maxPooling2Dsame_stride_input.json");
|
||||
|
||||
const circuit = await wasm_tester(path.join(__dirname, "circuits", "MaxPooling2Dsame_stride_test.circom"));
|
||||
|
||||
const witness = await circuit.calculateWitness(INPUT, true);
|
||||
|
||||
assert(Fr.eq(Fr.e(witness[0]),Fr.e(1)));
|
||||
});
|
||||
});
|
||||
5
test/circuits/MaxPooling2Dsame_stride_test.circom
Normal file
5
test/circuits/MaxPooling2Dsame_stride_test.circom
Normal file
@@ -0,0 +1,5 @@
|
||||
pragma circom 2.0.0;
|
||||
|
||||
include "../../circuits/MaxPooling2Dsame.circom";
|
||||
|
||||
component main = MaxPooling2Dsame(10, 10, 3, 2, 3);
|
||||
6
test/circuits/MaxPooling2Dsame_test.circom
Normal file
6
test/circuits/MaxPooling2Dsame_test.circom
Normal file
@@ -0,0 +1,6 @@
|
||||
pragma circom 2.0.0;
|
||||
|
||||
include "../../circuits/MaxPooling2Dsame.circom";
|
||||
|
||||
// poolSize=strides - default Keras settings
|
||||
component main = MaxPooling2Dsame(5, 5, 3, 2, 2);
|
||||
Reference in New Issue
Block a user