mirror of
https://github.com/wassname/keras-js.git
synced 2026-09-11 12:20:53 +08:00
implement UpSampling1D/2D/3D layers, with tests
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
/* eslint-env browser, mocha */
|
||||
|
||||
describe('convolutional layer: UpSampling1D', function () {
|
||||
const assert = chai.assert
|
||||
const styles = testGlobals.styles
|
||||
const logTime = testGlobals.logTime
|
||||
const stringifyCondensed = testGlobals.stringifyCondensed
|
||||
const approxEquals = KerasJS.testUtils.approxEquals
|
||||
const layers = KerasJS.layers
|
||||
|
||||
before(function () {
|
||||
console.log('\n%cconvolutional layer: UpSampling1D', styles.h1)
|
||||
})
|
||||
|
||||
it(`[convolutional.UpSampling1D.0] length 2 upsampling on 3x5 input`, function () {
|
||||
const key = `convolutional.UpSampling1D.0`
|
||||
console.log(`\n%c[${key}] length 2 upsampling on 3x5 input`, styles.h3)
|
||||
let testLayer = new layers.UpSampling1D(2)
|
||||
let t = new KerasJS.Tensor(TEST_DATA[key].input.data, TEST_DATA[key].input.shape)
|
||||
console.log('%cin', styles.h4, stringifyCondensed(t.tensor))
|
||||
const startTime = performance.now()
|
||||
t = testLayer.call(t)
|
||||
const endTime = performance.now()
|
||||
console.log('%cout', styles.h4, stringifyCondensed(t.tensor))
|
||||
logTime(startTime, endTime)
|
||||
const dataExpected = new Float32Array(TEST_DATA[key].expected.data)
|
||||
const shapeExpected = TEST_DATA[key].expected.shape
|
||||
assert.deepEqual(t.tensor.shape, shapeExpected)
|
||||
assert.isTrue(approxEquals(t.tensor, dataExpected))
|
||||
})
|
||||
|
||||
it(`[convolutional.UpSampling1D.1] length 3 upsampling on 4x4 input`, function () {
|
||||
const key = `convolutional.UpSampling1D.1`
|
||||
console.log(`\n%c[${key}] length 3 upsampling on 4x4 input`, styles.h3)
|
||||
let testLayer = new layers.UpSampling1D(3)
|
||||
let t = new KerasJS.Tensor(TEST_DATA[key].input.data, TEST_DATA[key].input.shape)
|
||||
console.log('%cin', styles.h4, stringifyCondensed(t.tensor))
|
||||
const startTime = performance.now()
|
||||
t = testLayer.call(t)
|
||||
const endTime = performance.now()
|
||||
console.log('%cout', styles.h4, stringifyCondensed(t.tensor))
|
||||
logTime(startTime, endTime)
|
||||
const dataExpected = new Float32Array(TEST_DATA[key].expected.data)
|
||||
const shapeExpected = TEST_DATA[key].expected.shape
|
||||
assert.deepEqual(t.tensor.shape, shapeExpected)
|
||||
assert.isTrue(approxEquals(t.tensor, dataExpected))
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,82 @@
|
||||
/* eslint-env browser, mocha */
|
||||
|
||||
describe('convolutional layer: UpSampling2D', function () {
|
||||
const assert = chai.assert
|
||||
const styles = testGlobals.styles
|
||||
const logTime = testGlobals.logTime
|
||||
const stringifyCondensed = testGlobals.stringifyCondensed
|
||||
const approxEquals = KerasJS.testUtils.approxEquals
|
||||
const layers = KerasJS.layers
|
||||
|
||||
before(function () {
|
||||
console.log('\n%cconvolutional layer: UpSampling2D', styles.h1)
|
||||
})
|
||||
|
||||
it(`[convolutional.UpSampling2D.0] size 2x2 upsampling on 3x3x3 input, dimOrdering=tf`, function () {
|
||||
const key = `convolutional.UpSampling2D.0`
|
||||
console.log(`\n%c[${key}] size 2x2 upsampling on 3x3x3 input, dimOrdering=tf`, styles.h3)
|
||||
let testLayer = new layers.UpSampling2D([2, 2], { dimOrdering: 'tf' })
|
||||
let t = new KerasJS.Tensor(TEST_DATA[key].input.data, TEST_DATA[key].input.shape)
|
||||
console.log('%cin', styles.h4, stringifyCondensed(t.tensor))
|
||||
const startTime = performance.now()
|
||||
t = testLayer.call(t)
|
||||
const endTime = performance.now()
|
||||
console.log('%cout', styles.h4, stringifyCondensed(t.tensor))
|
||||
logTime(startTime, endTime)
|
||||
const dataExpected = new Float32Array(TEST_DATA[key].expected.data)
|
||||
const shapeExpected = TEST_DATA[key].expected.shape
|
||||
assert.deepEqual(t.tensor.shape, shapeExpected)
|
||||
assert.isTrue(approxEquals(t.tensor, dataExpected))
|
||||
})
|
||||
|
||||
it(`[convolutional.UpSampling2D.1] size 2x2 upsampling on 3x3x3 input, dimOrdering=th`, function () {
|
||||
const key = `convolutional.UpSampling2D.1`
|
||||
console.log(`\n%c[${key}] size 2x2 upsampling on 3x3x3 input, dimOrdering=th`, styles.h3)
|
||||
let testLayer = new layers.UpSampling2D([2, 2], { dimOrdering: 'th' })
|
||||
let t = new KerasJS.Tensor(TEST_DATA[key].input.data, TEST_DATA[key].input.shape)
|
||||
console.log('%cin', styles.h4, stringifyCondensed(t.tensor))
|
||||
const startTime = performance.now()
|
||||
t = testLayer.call(t)
|
||||
const endTime = performance.now()
|
||||
console.log('%cout', styles.h4, stringifyCondensed(t.tensor))
|
||||
logTime(startTime, endTime)
|
||||
const dataExpected = new Float32Array(TEST_DATA[key].expected.data)
|
||||
const shapeExpected = TEST_DATA[key].expected.shape
|
||||
assert.deepEqual(t.tensor.shape, shapeExpected)
|
||||
assert.isTrue(approxEquals(t.tensor, dataExpected))
|
||||
})
|
||||
|
||||
it(`[convolutional.UpSampling2D.2] size 3x2 upsampling on 4x2x2 input, dimOrdering=tf`, function () {
|
||||
const key = `convolutional.UpSampling2D.2`
|
||||
console.log(`\n%c[${key}] size 3x2 upsampling on 4x2x2 input, dimOrdering=tf`, styles.h3)
|
||||
let testLayer = new layers.UpSampling2D([3, 2], { dimOrdering: 'tf' })
|
||||
let t = new KerasJS.Tensor(TEST_DATA[key].input.data, TEST_DATA[key].input.shape)
|
||||
console.log('%cin', styles.h4, stringifyCondensed(t.tensor))
|
||||
const startTime = performance.now()
|
||||
t = testLayer.call(t)
|
||||
const endTime = performance.now()
|
||||
console.log('%cout', styles.h4, stringifyCondensed(t.tensor))
|
||||
logTime(startTime, endTime)
|
||||
const dataExpected = new Float32Array(TEST_DATA[key].expected.data)
|
||||
const shapeExpected = TEST_DATA[key].expected.shape
|
||||
assert.deepEqual(t.tensor.shape, shapeExpected)
|
||||
assert.isTrue(approxEquals(t.tensor, dataExpected))
|
||||
})
|
||||
|
||||
it(`[convolutional.UpSampling2D.3] size 1x3 upsampling on 4x3x2 input, dimOrdering=th`, function () {
|
||||
const key = `convolutional.UpSampling2D.3`
|
||||
console.log(`\n%c[${key}] size 1x3 upsampling on 4x3x2 input, dimOrdering=th`, styles.h3)
|
||||
let testLayer = new layers.UpSampling2D([1, 3], { dimOrdering: 'th' })
|
||||
let t = new KerasJS.Tensor(TEST_DATA[key].input.data, TEST_DATA[key].input.shape)
|
||||
console.log('%cin', styles.h4, stringifyCondensed(t.tensor))
|
||||
const startTime = performance.now()
|
||||
t = testLayer.call(t)
|
||||
const endTime = performance.now()
|
||||
console.log('%cout', styles.h4, stringifyCondensed(t.tensor))
|
||||
logTime(startTime, endTime)
|
||||
const dataExpected = new Float32Array(TEST_DATA[key].expected.data)
|
||||
const shapeExpected = TEST_DATA[key].expected.shape
|
||||
assert.deepEqual(t.tensor.shape, shapeExpected)
|
||||
assert.isTrue(approxEquals(t.tensor, dataExpected))
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,82 @@
|
||||
/* eslint-env browser, mocha */
|
||||
|
||||
describe('convolutional layer: UpSampling3D', function () {
|
||||
const assert = chai.assert
|
||||
const styles = testGlobals.styles
|
||||
const logTime = testGlobals.logTime
|
||||
const stringifyCondensed = testGlobals.stringifyCondensed
|
||||
const approxEquals = KerasJS.testUtils.approxEquals
|
||||
const layers = KerasJS.layers
|
||||
|
||||
before(function () {
|
||||
console.log('\n%cconvolutional layer: UpSampling3D', styles.h1)
|
||||
})
|
||||
|
||||
it(`[convolutional.UpSampling3D.0] size 2x2x2 upsampling on 2x2x2x3 input, dimOrdering=tf`, function () {
|
||||
const key = `convolutional.UpSampling3D.0`
|
||||
console.log(`\n%c[${key}] size 2x2x2 upsampling on 2x2x2x3 input, dimOrdering=tf`, styles.h3)
|
||||
let testLayer = new layers.UpSampling3D([2, 2, 2], { dimOrdering: 'tf' })
|
||||
let t = new KerasJS.Tensor(TEST_DATA[key].input.data, TEST_DATA[key].input.shape)
|
||||
console.log('%cin', styles.h4, stringifyCondensed(t.tensor))
|
||||
const startTime = performance.now()
|
||||
t = testLayer.call(t)
|
||||
const endTime = performance.now()
|
||||
console.log('%cout', styles.h4, stringifyCondensed(t.tensor))
|
||||
logTime(startTime, endTime)
|
||||
const dataExpected = new Float32Array(TEST_DATA[key].expected.data)
|
||||
const shapeExpected = TEST_DATA[key].expected.shape
|
||||
assert.deepEqual(t.tensor.shape, shapeExpected)
|
||||
assert.isTrue(approxEquals(t.tensor, dataExpected))
|
||||
})
|
||||
|
||||
it(`[convolutional.UpSampling3D.1] size 2x2x2 upsampling on 2x2x2x3 input, dimOrdering=th`, function () {
|
||||
const key = `convolutional.UpSampling3D.1`
|
||||
console.log(`\n%c[${key}] size 2x2x2 upsampling on 2x2x2x3 input, dimOrdering=th`, styles.h3)
|
||||
let testLayer = new layers.UpSampling3D([2, 2, 2], { dimOrdering: 'th' })
|
||||
let t = new KerasJS.Tensor(TEST_DATA[key].input.data, TEST_DATA[key].input.shape)
|
||||
console.log('%cin', styles.h4, stringifyCondensed(t.tensor))
|
||||
const startTime = performance.now()
|
||||
t = testLayer.call(t)
|
||||
const endTime = performance.now()
|
||||
console.log('%cout', styles.h4, stringifyCondensed(t.tensor))
|
||||
logTime(startTime, endTime)
|
||||
const dataExpected = new Float32Array(TEST_DATA[key].expected.data)
|
||||
const shapeExpected = TEST_DATA[key].expected.shape
|
||||
assert.deepEqual(t.tensor.shape, shapeExpected)
|
||||
assert.isTrue(approxEquals(t.tensor, dataExpected))
|
||||
})
|
||||
|
||||
it(`[convolutional.UpSampling3D.2] size 1x3x2 upsampling on 2x1x3x2 input, dimOrdering=tf`, function () {
|
||||
const key = `convolutional.UpSampling3D.2`
|
||||
console.log(`\n%c[${key}] size 1x3x2 upsampling on 2x1x3x2 input, dimOrdering=tf`, styles.h3)
|
||||
let testLayer = new layers.UpSampling3D([1, 3, 2], { dimOrdering: 'tf' })
|
||||
let t = new KerasJS.Tensor(TEST_DATA[key].input.data, TEST_DATA[key].input.shape)
|
||||
console.log('%cin', styles.h4, stringifyCondensed(t.tensor))
|
||||
const startTime = performance.now()
|
||||
t = testLayer.call(t)
|
||||
const endTime = performance.now()
|
||||
console.log('%cout', styles.h4, stringifyCondensed(t.tensor))
|
||||
logTime(startTime, endTime)
|
||||
const dataExpected = new Float32Array(TEST_DATA[key].expected.data)
|
||||
const shapeExpected = TEST_DATA[key].expected.shape
|
||||
assert.deepEqual(t.tensor.shape, shapeExpected)
|
||||
assert.isTrue(approxEquals(t.tensor, dataExpected))
|
||||
})
|
||||
|
||||
it(`[convolutional.UpSampling3D.3] 2x1x2 upsampling on 2x1x3x3 input, dimOrdering=th`, function () {
|
||||
const key = `convolutional.UpSampling3D.3`
|
||||
console.log(`\n%c[${key}] 2x1x2 upsampling on 2x1x3x3 input, dimOrdering=th`, styles.h3)
|
||||
let testLayer = new layers.UpSampling3D([2, 1, 2], { dimOrdering: 'th' })
|
||||
let t = new KerasJS.Tensor(TEST_DATA[key].input.data, TEST_DATA[key].input.shape)
|
||||
console.log('%cin', styles.h4, stringifyCondensed(t.tensor))
|
||||
const startTime = performance.now()
|
||||
t = testLayer.call(t)
|
||||
const endTime = performance.now()
|
||||
console.log('%cout', styles.h4, stringifyCondensed(t.tensor))
|
||||
logTime(startTime, endTime)
|
||||
const dataExpected = new Float32Array(TEST_DATA[key].expected.data)
|
||||
const shapeExpected = TEST_DATA[key].expected.shape
|
||||
assert.deepEqual(t.tensor.shape, shapeExpected)
|
||||
assert.isTrue(approxEquals(t.tensor, dataExpected))
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,30 @@
|
||||
// TEST DATA
|
||||
// Keyed by mocha test ID
|
||||
// Python code for generating test data can be found in the matching jupyter notebook in folder `notebooks/`.
|
||||
|
||||
(function () {
|
||||
var DATA = {
|
||||
'convolutional.UpSampling1D.0': {
|
||||
input: {
|
||||
data: [0.262, 0.764609, -0.482897, -0.371755, 0.871769, 0.490033, -0.986894, -0.960468, 0.373039, 0.911356, 0.00298, 0.270652, 0.749006, 0.692235, 0.471778],
|
||||
shape: [3, 5]
|
||||
},
|
||||
expected: {
|
||||
data: [0.262, 0.764609, -0.482897, -0.371755, 0.871769, 0.262, 0.764609, -0.482897, -0.371755, 0.871769, 0.490033, -0.986894, -0.960468, 0.373039, 0.911356, 0.490033, -0.986894, -0.960468, 0.373039, 0.911356, 0.00298, 0.270652, 0.749006, 0.692235, 0.471778, 0.00298, 0.270652, 0.749006, 0.692235, 0.471778],
|
||||
shape: [6, 5]
|
||||
}
|
||||
},
|
||||
'convolutional.UpSampling1D.1': {
|
||||
input: {
|
||||
data: [0.562988, 0.168418, -0.14658, -0.369311, 0.653777, 0.806859, -0.922124, 0.830445, -0.878989, -0.638546, -0.855401, -0.082476, 0.416718, -0.03353, -0.949107, -0.866195],
|
||||
shape: [4, 4]
|
||||
},
|
||||
expected: {
|
||||
data: [0.562988, 0.168418, -0.14658, -0.369311, 0.562988, 0.168418, -0.14658, -0.369311, 0.562988, 0.168418, -0.14658, -0.369311, 0.653777, 0.806859, -0.922124, 0.830445, 0.653777, 0.806859, -0.922124, 0.830445, 0.653777, 0.806859, -0.922124, 0.830445, -0.878989, -0.638546, -0.855401, -0.082476, -0.878989, -0.638546, -0.855401, -0.082476, -0.878989, -0.638546, -0.855401, -0.082476, 0.416718, -0.03353, -0.949107, -0.866195, 0.416718, -0.03353, -0.949107, -0.866195, 0.416718, -0.03353, -0.949107, -0.866195],
|
||||
shape: [12, 4]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.TEST_DATA = Object.assign({}, window.TEST_DATA, DATA)
|
||||
})()
|
||||
@@ -0,0 +1,50 @@
|
||||
// TEST DATA
|
||||
// Keyed by mocha test ID
|
||||
// Python code for generating test data can be found in the matching jupyter notebook in folder `notebooks/`.
|
||||
|
||||
(function () {
|
||||
var DATA = {
|
||||
'convolutional.UpSampling2D.0': {
|
||||
input: {
|
||||
data: [-0.570441, -0.454673, -0.285321, 0.237249, 0.282682, 0.428035, 0.160547, -0.332203, 0.546391, 0.272735, 0.010827, -0.763164, -0.442696, 0.381948, -0.676994, 0.753553, -0.031788, 0.915329, -0.738844, 0.269075, 0.434091, 0.991585, -0.944288, 0.258834, 0.162138, 0.565201, -0.492094],
|
||||
shape: [3, 3, 3]
|
||||
},
|
||||
expected: {
|
||||
data: [-0.570441, -0.454673, -0.285321, -0.570441, -0.454673, -0.285321, 0.237249, 0.282682, 0.428035, 0.237249, 0.282682, 0.428035, 0.160547, -0.332203, 0.546391, 0.160547, -0.332203, 0.546391, -0.570441, -0.454673, -0.285321, -0.570441, -0.454673, -0.285321, 0.237249, 0.282682, 0.428035, 0.237249, 0.282682, 0.428035, 0.160547, -0.332203, 0.546391, 0.160547, -0.332203, 0.546391, 0.272735, 0.010827, -0.763164, 0.272735, 0.010827, -0.763164, -0.442696, 0.381948, -0.676994, -0.442696, 0.381948, -0.676994, 0.753553, -0.031788, 0.915329, 0.753553, -0.031788, 0.915329, 0.272735, 0.010827, -0.763164, 0.272735, 0.010827, -0.763164, -0.442696, 0.381948, -0.676994, -0.442696, 0.381948, -0.676994, 0.753553, -0.031788, 0.915329, 0.753553, -0.031788, 0.915329, -0.738844, 0.269075, 0.434091, -0.738844, 0.269075, 0.434091, 0.991585, -0.944288, 0.258834, 0.991585, -0.944288, 0.258834, 0.162138, 0.565201, -0.492094, 0.162138, 0.565201, -0.492094, -0.738844, 0.269075, 0.434091, -0.738844, 0.269075, 0.434091, 0.991585, -0.944288, 0.258834, 0.991585, -0.944288, 0.258834, 0.162138, 0.565201, -0.492094, 0.162138, 0.565201, -0.492094],
|
||||
shape: [6, 6, 3]
|
||||
}
|
||||
},
|
||||
'convolutional.UpSampling2D.1': {
|
||||
input: {
|
||||
data: [-0.570441, -0.454673, -0.285321, 0.237249, 0.282682, 0.428035, 0.160547, -0.332203, 0.546391, 0.272735, 0.010827, -0.763164, -0.442696, 0.381948, -0.676994, 0.753553, -0.031788, 0.915329, -0.738844, 0.269075, 0.434091, 0.991585, -0.944288, 0.258834, 0.162138, 0.565201, -0.492094],
|
||||
shape: [3, 3, 3]
|
||||
},
|
||||
expected: {
|
||||
data: [-0.570441, -0.570441, -0.454673, -0.454673, -0.285321, -0.285321, -0.570441, -0.570441, -0.454673, -0.454673, -0.285321, -0.285321, 0.237249, 0.237249, 0.282682, 0.282682, 0.428035, 0.428035, 0.237249, 0.237249, 0.282682, 0.282682, 0.428035, 0.428035, 0.160547, 0.160547, -0.332203, -0.332203, 0.546391, 0.546391, 0.160547, 0.160547, -0.332203, -0.332203, 0.546391, 0.546391, 0.272735, 0.272735, 0.010827, 0.010827, -0.763164, -0.763164, 0.272735, 0.272735, 0.010827, 0.010827, -0.763164, -0.763164, -0.442696, -0.442696, 0.381948, 0.381948, -0.676994, -0.676994, -0.442696, -0.442696, 0.381948, 0.381948, -0.676994, -0.676994, 0.753553, 0.753553, -0.031788, -0.031788, 0.915329, 0.915329, 0.753553, 0.753553, -0.031788, -0.031788, 0.915329, 0.915329, -0.738844, -0.738844, 0.269075, 0.269075, 0.434091, 0.434091, -0.738844, -0.738844, 0.269075, 0.269075, 0.434091, 0.434091, 0.991585, 0.991585, -0.944288, -0.944288, 0.258834, 0.258834, 0.991585, 0.991585, -0.944288, -0.944288, 0.258834, 0.258834, 0.162138, 0.162138, 0.565201, 0.565201, -0.492094, -0.492094, 0.162138, 0.162138, 0.565201, 0.565201, -0.492094, -0.492094],
|
||||
shape: [3, 6, 6]
|
||||
}
|
||||
},
|
||||
'convolutional.UpSampling2D.2': {
|
||||
input: {
|
||||
data: [0.275222, -0.793967, -0.468107, -0.841484, -0.295362, 0.78175, 0.068787, -0.261747, -0.625733, -0.042907, 0.861141, 0.85267, 0.956439, 0.717838, -0.99869, -0.963008],
|
||||
shape: [4, 2, 2]
|
||||
},
|
||||
expected: {
|
||||
data: [0.275222, -0.793967, 0.275222, -0.793967, -0.468107, -0.841484, -0.468107, -0.841484, 0.275222, -0.793967, 0.275222, -0.793967, -0.468107, -0.841484, -0.468107, -0.841484, 0.275222, -0.793967, 0.275222, -0.793967, -0.468107, -0.841484, -0.468107, -0.841484, -0.295362, 0.78175, -0.295362, 0.78175, 0.068787, -0.261747, 0.068787, -0.261747, -0.295362, 0.78175, -0.295362, 0.78175, 0.068787, -0.261747, 0.068787, -0.261747, -0.295362, 0.78175, -0.295362, 0.78175, 0.068787, -0.261747, 0.068787, -0.261747, -0.625733, -0.042907, -0.625733, -0.042907, 0.861141, 0.85267, 0.861141, 0.85267, -0.625733, -0.042907, -0.625733, -0.042907, 0.861141, 0.85267, 0.861141, 0.85267, -0.625733, -0.042907, -0.625733, -0.042907, 0.861141, 0.85267, 0.861141, 0.85267, 0.956439, 0.717838, 0.956439, 0.717838, -0.99869, -0.963008, -0.99869, -0.963008, 0.956439, 0.717838, 0.956439, 0.717838, -0.99869, -0.963008, -0.99869, -0.963008, 0.956439, 0.717838, 0.956439, 0.717838, -0.99869, -0.963008, -0.99869, -0.963008],
|
||||
shape: [12, 4, 2]
|
||||
}
|
||||
},
|
||||
'convolutional.UpSampling2D.3': {
|
||||
input: {
|
||||
data: [-0.989173, -0.133618, -0.505338, 0.023259, 0.503982, -0.303769, -0.436321, 0.793911, 0.416102, 0.806405, -0.098342, -0.738022, -0.982676, 0.805073, 0.741244, -0.941634, -0.253526, -0.136544, -0.295772, 0.207565, -0.517246, -0.686963, -0.176235, -0.354111],
|
||||
shape: [4, 3, 2]
|
||||
},
|
||||
expected: {
|
||||
data: [-0.989173, -0.989173, -0.989173, -0.133618, -0.133618, -0.133618, -0.505338, -0.505338, -0.505338, 0.023259, 0.023259, 0.023259, 0.503982, 0.503982, 0.503982, -0.303769, -0.303769, -0.303769, -0.436321, -0.436321, -0.436321, 0.793911, 0.793911, 0.793911, 0.416102, 0.416102, 0.416102, 0.806405, 0.806405, 0.806405, -0.098342, -0.098342, -0.098342, -0.738022, -0.738022, -0.738022, -0.982676, -0.982676, -0.982676, 0.805073, 0.805073, 0.805073, 0.741244, 0.741244, 0.741244, -0.941634, -0.941634, -0.941634, -0.253526, -0.253526, -0.253526, -0.136544, -0.136544, -0.136544, -0.295772, -0.295772, -0.295772, 0.207565, 0.207565, 0.207565, -0.517246, -0.517246, -0.517246, -0.686963, -0.686963, -0.686963, -0.176235, -0.176235, -0.176235, -0.354111, -0.354111, -0.354111],
|
||||
shape: [4, 3, 6]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.TEST_DATA = Object.assign({}, window.TEST_DATA, DATA)
|
||||
})()
|
||||
@@ -0,0 +1,50 @@
|
||||
// TEST DATA
|
||||
// Keyed by mocha test ID
|
||||
// Python code for generating test data can be found in the matching jupyter notebook in folder `notebooks/`.
|
||||
|
||||
(function () {
|
||||
var DATA = {
|
||||
'convolutional.UpSampling3D.0': {
|
||||
input: {
|
||||
data: [-0.806777, -0.564841, -0.481331, 0.559626, 0.274958, -0.659222, -0.178541, 0.689453, -0.028873, 0.053859, -0.446394, -0.53406, 0.776897, -0.700858, -0.802179, -0.616515, 0.718677, 0.303042, -0.080606, -0.850593, -0.795971, 0.860487, -0.90685, 0.89858],
|
||||
shape: [2, 2, 2, 3]
|
||||
},
|
||||
expected: {
|
||||
data: [-0.806777, -0.564841, -0.481331, -0.806777, -0.564841, -0.481331, 0.559626, 0.274958, -0.659222, 0.559626, 0.274958, -0.659222, -0.806777, -0.564841, -0.481331, -0.806777, -0.564841, -0.481331, 0.559626, 0.274958, -0.659222, 0.559626, 0.274958, -0.659222, -0.178541, 0.689453, -0.028873, -0.178541, 0.689453, -0.028873, 0.053859, -0.446394, -0.53406, 0.053859, -0.446394, -0.53406, -0.178541, 0.689453, -0.028873, -0.178541, 0.689453, -0.028873, 0.053859, -0.446394, -0.53406, 0.053859, -0.446394, -0.53406, -0.806777, -0.564841, -0.481331, -0.806777, -0.564841, -0.481331, 0.559626, 0.274958, -0.659222, 0.559626, 0.274958, -0.659222, -0.806777, -0.564841, -0.481331, -0.806777, -0.564841, -0.481331, 0.559626, 0.274958, -0.659222, 0.559626, 0.274958, -0.659222, -0.178541, 0.689453, -0.028873, -0.178541, 0.689453, -0.028873, 0.053859, -0.446394, -0.53406, 0.053859, -0.446394, -0.53406, -0.178541, 0.689453, -0.028873, -0.178541, 0.689453, -0.028873, 0.053859, -0.446394, -0.53406, 0.053859, -0.446394, -0.53406, 0.776897, -0.700858, -0.802179, 0.776897, -0.700858, -0.802179, -0.616515, 0.718677, 0.303042, -0.616515, 0.718677, 0.303042, 0.776897, -0.700858, -0.802179, 0.776897, -0.700858, -0.802179, -0.616515, 0.718677, 0.303042, -0.616515, 0.718677, 0.303042, -0.080606, -0.850593, -0.795971, -0.080606, -0.850593, -0.795971, 0.860487, -0.90685, 0.89858, 0.860487, -0.90685, 0.89858, -0.080606, -0.850593, -0.795971, -0.080606, -0.850593, -0.795971, 0.860487, -0.90685, 0.89858, 0.860487, -0.90685, 0.89858, 0.776897, -0.700858, -0.802179, 0.776897, -0.700858, -0.802179, -0.616515, 0.718677, 0.303042, -0.616515, 0.718677, 0.303042, 0.776897, -0.700858, -0.802179, 0.776897, -0.700858, -0.802179, -0.616515, 0.718677, 0.303042, -0.616515, 0.718677, 0.303042, -0.080606, -0.850593, -0.795971, -0.080606, -0.850593, -0.795971, 0.860487, -0.90685, 0.89858, 0.860487, -0.90685, 0.89858, -0.080606, -0.850593, -0.795971, -0.080606, -0.850593, -0.795971, 0.860487, -0.90685, 0.89858, 0.860487, -0.90685, 0.89858],
|
||||
shape: [4, 4, 4, 3]
|
||||
}
|
||||
},
|
||||
'convolutional.UpSampling3D.1': {
|
||||
input: {
|
||||
data: [-0.806777, -0.564841, -0.481331, 0.559626, 0.274958, -0.659222, -0.178541, 0.689453, -0.028873, 0.053859, -0.446394, -0.53406, 0.776897, -0.700858, -0.802179, -0.616515, 0.718677, 0.303042, -0.080606, -0.850593, -0.795971, 0.860487, -0.90685, 0.89858],
|
||||
shape: [2, 2, 2, 3]
|
||||
},
|
||||
expected: {
|
||||
data: [-0.806777, -0.806777, -0.564841, -0.564841, -0.481331, -0.481331, -0.806777, -0.806777, -0.564841, -0.564841, -0.481331, -0.481331, 0.559626, 0.559626, 0.274958, 0.274958, -0.659222, -0.659222, 0.559626, 0.559626, 0.274958, 0.274958, -0.659222, -0.659222, -0.806777, -0.806777, -0.564841, -0.564841, -0.481331, -0.481331, -0.806777, -0.806777, -0.564841, -0.564841, -0.481331, -0.481331, 0.559626, 0.559626, 0.274958, 0.274958, -0.659222, -0.659222, 0.559626, 0.559626, 0.274958, 0.274958, -0.659222, -0.659222, -0.178541, -0.178541, 0.689453, 0.689453, -0.028873, -0.028873, -0.178541, -0.178541, 0.689453, 0.689453, -0.028873, -0.028873, 0.053859, 0.053859, -0.446394, -0.446394, -0.53406, -0.53406, 0.053859, 0.053859, -0.446394, -0.446394, -0.53406, -0.53406, -0.178541, -0.178541, 0.689453, 0.689453, -0.028873, -0.028873, -0.178541, -0.178541, 0.689453, 0.689453, -0.028873, -0.028873, 0.053859, 0.053859, -0.446394, -0.446394, -0.53406, -0.53406, 0.053859, 0.053859, -0.446394, -0.446394, -0.53406, -0.53406, 0.776897, 0.776897, -0.700858, -0.700858, -0.802179, -0.802179, 0.776897, 0.776897, -0.700858, -0.700858, -0.802179, -0.802179, -0.616515, -0.616515, 0.718677, 0.718677, 0.303042, 0.303042, -0.616515, -0.616515, 0.718677, 0.718677, 0.303042, 0.303042, 0.776897, 0.776897, -0.700858, -0.700858, -0.802179, -0.802179, 0.776897, 0.776897, -0.700858, -0.700858, -0.802179, -0.802179, -0.616515, -0.616515, 0.718677, 0.718677, 0.303042, 0.303042, -0.616515, -0.616515, 0.718677, 0.718677, 0.303042, 0.303042, -0.080606, -0.080606, -0.850593, -0.850593, -0.795971, -0.795971, -0.080606, -0.080606, -0.850593, -0.850593, -0.795971, -0.795971, 0.860487, 0.860487, -0.90685, -0.90685, 0.89858, 0.89858, 0.860487, 0.860487, -0.90685, -0.90685, 0.89858, 0.89858, -0.080606, -0.080606, -0.850593, -0.850593, -0.795971, -0.795971, -0.080606, -0.080606, -0.850593, -0.850593, -0.795971, -0.795971, 0.860487, 0.860487, -0.90685, -0.90685, 0.89858, 0.89858, 0.860487, 0.860487, -0.90685, -0.90685, 0.89858, 0.89858],
|
||||
shape: [2, 4, 4, 6]
|
||||
}
|
||||
},
|
||||
'convolutional.UpSampling3D.2': {
|
||||
input: {
|
||||
data: [-0.989173, -0.133618, -0.505338, 0.023259, 0.503982, -0.303769, -0.436321, 0.793911, 0.416102, 0.806405, -0.098342, -0.738022],
|
||||
shape: [2, 1, 3, 2]
|
||||
},
|
||||
expected: {
|
||||
data: [-0.989173, -0.133618, -0.989173, -0.133618, -0.505338, 0.023259, -0.505338, 0.023259, 0.503982, -0.303769, 0.503982, -0.303769, -0.989173, -0.133618, -0.989173, -0.133618, -0.505338, 0.023259, -0.505338, 0.023259, 0.503982, -0.303769, 0.503982, -0.303769, -0.989173, -0.133618, -0.989173, -0.133618, -0.505338, 0.023259, -0.505338, 0.023259, 0.503982, -0.303769, 0.503982, -0.303769, -0.436321, 0.793911, -0.436321, 0.793911, 0.416102, 0.806405, 0.416102, 0.806405, -0.098342, -0.738022, -0.098342, -0.738022, -0.436321, 0.793911, -0.436321, 0.793911, 0.416102, 0.806405, 0.416102, 0.806405, -0.098342, -0.738022, -0.098342, -0.738022, -0.436321, 0.793911, -0.436321, 0.793911, 0.416102, 0.806405, 0.416102, 0.806405, -0.098342, -0.738022, -0.098342, -0.738022],
|
||||
shape: [2, 3, 6, 2]
|
||||
}
|
||||
},
|
||||
'convolutional.UpSampling3D.3': {
|
||||
input: {
|
||||
data: [-0.47588, 0.366985, 0.040173, 0.015578, -0.906159, 0.241982, -0.771299, -0.443554, -0.56404, -0.17751, 0.541277, -0.233327, 0.024369, 0.858275, 0.496191, 0.980574, -0.59522, 0.480899],
|
||||
shape: [2, 1, 3, 3]
|
||||
},
|
||||
expected: {
|
||||
data: [-0.47588, -0.47588, 0.366985, 0.366985, 0.040173, 0.040173, 0.015578, 0.015578, -0.906159, -0.906159, 0.241982, 0.241982, -0.771299, -0.771299, -0.443554, -0.443554, -0.56404, -0.56404, -0.47588, -0.47588, 0.366985, 0.366985, 0.040173, 0.040173, 0.015578, 0.015578, -0.906159, -0.906159, 0.241982, 0.241982, -0.771299, -0.771299, -0.443554, -0.443554, -0.56404, -0.56404, -0.17751, -0.17751, 0.541277, 0.541277, -0.233327, -0.233327, 0.024369, 0.024369, 0.858275, 0.858275, 0.496191, 0.496191, 0.980574, 0.980574, -0.59522, -0.59522, 0.480899, 0.480899, -0.17751, -0.17751, 0.541277, 0.541277, -0.233327, -0.233327, 0.024369, 0.024369, 0.858275, 0.858275, 0.496191, 0.496191, 0.980574, 0.980574, -0.59522, -0.59522, 0.480899, 0.480899],
|
||||
shape: [2, 2, 3, 6]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.TEST_DATA = Object.assign({}, window.TEST_DATA, DATA)
|
||||
})()
|
||||
Reference in New Issue
Block a user