Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions tools/test/test_wavenet_configurable_gating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,24 +299,35 @@ class TestConfigurableGating

// Set some weights to make the layers produce different outputs
std::vector<float> weights;
// Add weights for conv layer (simplified - just enough to make it non-zero)
const int conv_weights = channels * 2 * bottleneck * kernelSize; // 2*bottleneck for gated
// Add weights for conv layer (2*bottleneck outputs for gated), including bias
const int conv_out_channels = 2 * bottleneck;
const int conv_weights = channels * conv_out_channels * kernelSize;
const int conv_bias = conv_out_channels;
for (int i = 0; i < conv_weights; i++)
{
weights.push_back(0.1f * i);
}
for (int i = 0; i < conv_bias; i++)
{
weights.push_back(0.01f * i);
}
// Add weights for input mixin
const int mixin_weights = conditionSize * 2 * bottleneck;
for (int i = 0; i < mixin_weights; i++)
{
weights.push_back(0.05f * i);
}
// Add weights for 1x1 conv
// Add weights for 1x1 conv, including bias
const int conv1x1_weights = bottleneck * channels;
const int conv1x1_bias = channels;
for (int i = 0; i < conv1x1_weights; i++)
{
weights.push_back(0.02f * i);
}
for (int i = 0; i < conv1x1_bias; i++)
{
weights.push_back(0.03f * i);
}

// Set weights for all layers
auto weights_iter = weights.begin();
Expand All @@ -328,6 +339,8 @@ class TestConfigurableGating
weights_iter = weights.begin();
layer_relu.set_weights_(weights_iter);

assert(weights_iter == weights.end());

// Create some test input data
Eigen::MatrixXf input(channels, num_frames);
input.setRandom();
Expand Down Expand Up @@ -375,4 +388,4 @@ void run_configurable_gating_tests()
test_wavenet_configurable_gating::TestConfigurableGating::test_layer_array_construction();
test_wavenet_configurable_gating::TestConfigurableGating::test_json_configuration_parsing();
test_wavenet_configurable_gating::TestConfigurableGating::test_activation_function_behavior();
}
}
Loading