-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initializer compatibility test (#67)
* Add initializer test * Fix initializers in Theano * Tweak layer and optimizer test * Add version print
- Loading branch information
Showing
32 changed files
with
355 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
initializer: | ||
name: Constant | ||
args: | ||
value: 3.2 | ||
|
||
test_config: | ||
shape: [4, 3, 2, 1] | ||
|
||
compare_config: | ||
threshold: !!float 1e-4 | ||
mean: 3.2 | ||
std: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
initializer: | ||
name: Normal | ||
args: | ||
mean: &mean 5.3 | ||
stddev: &stddev 9.0 | ||
|
||
test_config: | ||
shape: [32, 16, 4, 4] | ||
|
||
compare_config: | ||
mean: *mean | ||
std: *stddev | ||
threshold: 0.05 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
initializer: | ||
name: Uniform | ||
args: | ||
minval: -2.0 | ||
maxval: 6.0 | ||
|
||
test_config: | ||
shape: [16, 16, 8, 8] | ||
|
||
compare_config: | ||
threshold: 0.03 | ||
mean: 2.0 | ||
std: 2.309 # (maxval - min_val) / sqrt(12) | ||
|
20 changes: 20 additions & 0 deletions
20
tests/integration/data/initializer/xavier_conv2d_normal.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
initializer: | ||
name: XavierConv2D | ||
args: | ||
uniform: False | ||
|
||
test_config: | ||
shape: [64, 32, 8, 8] | ||
|
||
compare_config: | ||
threshold: 0.1 | ||
mean: 0.0 | ||
std: 0.0168 | ||
# Standard deviation here is not that of normal distribution, but of truncated normal distribution | ||
# with bound of `2 * standard deviation of normal distribution`. | ||
# To get this you can use scipy.stats.truncnorm class. | ||
# | ||
# fan_out, fan_in = 64 * 8 * 8, 32 * 8 * 8 | ||
# scale = np.sqrt(3. / (fan_in + fan_out)) | ||
# variance = truncnorm.stats(-2, 2, scale=scale, moments='v') | ||
# std = np.sqrt(variance) |
19 changes: 19 additions & 0 deletions
19
tests/integration/data/initializer/xavier_conv2d_uniform.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
initializer: | ||
name: XavierConv2D | ||
args: | ||
uniform: True | ||
|
||
test_config: | ||
shape: [64, 32, 8, 8] | ||
|
||
compare_config: | ||
threshold: 0.03 | ||
mean: 0.0 | ||
std: 0.01804 | ||
# Standard deviation here is not that of normal distribution, but of truncated normal distribution | ||
# with bound of `2 * standard deviation of normal distribution`. | ||
# To get this you can use scipy.stats.truncnorm class. | ||
# | ||
# fan_out, fan_in = 64 * 8 * 8, 32 * 8 * 8 | ||
# scale = np.sqrt(6. / (fan_in + fan_out)) | ||
# std = (scale + scale) / sqrt(12) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
initializer: | ||
name: Xavier | ||
args: | ||
uniform: False | ||
|
||
test_config: | ||
shape: [1000, 100] | ||
|
||
compare_config: | ||
threshold: 0.1 | ||
mean: 0.0 | ||
std: 0.03984 | ||
# Standard deviation here is not that of normal distribution, but of truncated normal distribution | ||
# with bound of `2 * standard deviation of normal distribution`. | ||
# To get this you can use scipy.stats.tnorm class. | ||
# | ||
# fan_out, fan_in = 1000, 100 | ||
# scale = np.sqrt(3. / (fan_in + fan_out)) | ||
# variance = tnorm.stats(-2, 2, scale=scale, moments='v') | ||
# std = np.sqrt(variance) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
initializer: | ||
name: Xavier | ||
args: | ||
uniform: True | ||
|
||
test_config: | ||
shape: [64, 32] | ||
|
||
compare_config: | ||
threshold: 0.03 | ||
mean: 0.0 | ||
std: 0.1443 | ||
# Standard deviation here is not that of normal distribution, but of truncated normal distribution | ||
# with bound of `2 * standard deviation of normal distribution`. | ||
# To get this you can use scipy.stats.truncnorm class. | ||
# | ||
# fan_out, fan_in = 16, 32 | ||
# scale = np.sqrt(6. / (fan_in + fan_out)) | ||
# std = (scale + scale) / sqrt(12) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
run: | ||
iteration: 10 | ||
|
||
|
@@ -13,4 +12,3 @@ layer: | |
input: input_randn_3x5_offset_3.h5 | ||
|
||
parameter: parameter_bn.h5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
run: | ||
iteration: 10 | ||
|
||
|
@@ -13,4 +12,3 @@ layer: | |
input: input_randn_3x5_offset_3.h5 | ||
|
||
parameter: parameter_bn.h5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
run: | ||
iteration: 10 | ||
|
||
|
@@ -13,4 +12,3 @@ layer: | |
input: input_randn_3x5_offset_3.h5 | ||
|
||
parameter: parameter_bn.h5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
layer: | ||
name: Dense | ||
args: | ||
|
@@ -8,4 +7,3 @@ layer: | |
input: input_randn_5x3.h5 | ||
|
||
parameter: parameter_randn_3x7.h5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
layer: | ||
name: Dense | ||
args: | ||
|
@@ -8,4 +7,3 @@ layer: | |
input: input_randn_5x3.h5 | ||
|
||
parameter: parameter_randn_3x7.h5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
|
||
layer: | ||
name: Flatten | ||
args: {} | ||
|
||
input: input_mnist_10x4x28x27.h5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
|
||
layer: | ||
name: ReLU | ||
args: {} | ||
|
||
input: input_randn_5x3.h5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
|
||
layer: | ||
name: Sigmoid | ||
args: {} | ||
|
||
input: input_randn_5x3.h5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
|
||
layer: | ||
name: Softmax | ||
args: {} | ||
|
||
input: input_randn_5x3.h5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
|
||
layer: | ||
name: TrueDiv | ||
args: | ||
denom: 255 | ||
|
||
input: input_randint_1x3x5x7.h5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
set -u | ||
|
||
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
DATA_DIR="${BASE_DIR}/data/initializer" | ||
TEST_DIR="${BASE_DIR}/test_initializer_compatibility" | ||
TEST_COMMAND="${TEST_DIR}/test_initializer_compatibility.sh" | ||
|
||
RETURN=0 | ||
for FILE in ${DATA_DIR}/*.yml | ||
do | ||
"${TEST_COMMAND}" "${FILE}" | ||
if [[ ! $? = 0 ]]; then | ||
RETURN=1 | ||
fi | ||
done | ||
|
||
exit ${RETURN} |
Oops, something went wrong.