Skip to content

Commit

Permalink
receptive_field
Browse files Browse the repository at this point in the history
  • Loading branch information
olilarkin committed May 4, 2024
1 parent df723f7 commit 86a9ca4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions NAM/dsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ void nam::DSP::Finalize(const int numFrames) {}

// Buffer =====================================================================

nam::Buffer::Buffer(const int receptive_field, const double expected_sample_rate)
nam::Buffer::Buffer(const int receptiveField, const double expected_sample_rate)
: nam::DSP(expected_sample_rate)
{
this->SetReceptiveField(receptive_field);
this->SetReceptiveField(receptiveField);
}

void nam::Buffer::SetReceptiveField(const int newReceptiveField)
Expand Down Expand Up @@ -136,20 +136,20 @@ void nam::Buffer::Finalize(const int numFrames)

// Linear =====================================================================

nam::Linear::Linear(const int receptive_field, const bool _bias, const std::vector<float>& weights,
nam::Linear::Linear(const int receptiveField, const bool _bias, const std::vector<float>& weights,
const double expected_sample_rate)
: nam::Buffer(receptive_field, expected_sample_rate)
: nam::Buffer(receptiveField, expected_sample_rate)
{
if ((int)weights.size() != (receptive_field + (_bias ? 1 : 0)))
if ((int)weights.size() != (receptiveField + (_bias ? 1 : 0)))
throw std::runtime_error(
"Params vector does not match expected size based "
"on architecture parameters");

this->_weight.resize(this->mReceptiveField);
// Pass in in reverse order so that dot products work out of the box.
for (int i = 0; i < this->mReceptiveField; i++)
this->_weight(i) = weights[receptive_field - 1 - i];
this->_bias = _bias ? weights[receptive_field] : (float)0.0;
this->_weight(i) = weights[receptiveField - 1 - i];
this->_bias = _bias ? weights[receptiveField] : (float)0.0;
}

void nam::Linear::Process(float* input, float* output, const int numFrames)
Expand Down
4 changes: 2 additions & 2 deletions NAM/dsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class DSP
class Buffer : public DSP
{
public:
Buffer(const int receptive_field, const double expected_sample_rate = -1.0);
Buffer(const int receptiveField, const double expected_sample_rate = -1.0);
void Finalize(const int numFrames);

protected:
Expand All @@ -104,7 +104,7 @@ class Buffer : public DSP
class Linear : public Buffer
{
public:
Linear(const int receptive_field, const bool _bias, const std::vector<float>& weights,
Linear(const int receptiveField, const bool _bias, const std::vector<float>& weights,
const double expected_sample_rate = -1.0);
void Process(float* input, float* output, const int numFrames) override;

Expand Down
4 changes: 2 additions & 2 deletions NAM/get_dsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ std::unique_ptr<DSP> get_dsp(dspData& conf)
std::unique_ptr<DSP> out = nullptr;
if (architecture == "Linear")
{
const int receptive_field = config["receptive_field"];
const int receptiveField = config["receptiveField"];
const bool _bias = config["bias"];
out = std::make_unique<Linear>(receptive_field, _bias, weights, expectedSampleRate);
out = std::make_unique<Linear>(receptiveField, _bias, weights, expectedSampleRate);
}
else if (architecture == "ConvNet")
{
Expand Down
4 changes: 2 additions & 2 deletions NAM/wavenet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ nam::wavenet::_LayerArray::_LayerArray(const int input_size, const int condition
{
for (size_t i = 0; i < dilations.size(); i++)
this->_layers.push_back(_Layer(condition_size, channels, kernel_size, dilations[i], activation, gated));
const long receptive_field = this->_get_receptive_field();
const long receptiveField = this->_get_receptive_field();
for (size_t i = 0; i < dilations.size(); i++)
{
this->_layer_buffers.push_back(Eigen::MatrixXf(channels, LAYER_ARRAY_BUFFER_SIZE + receptive_field - 1));
this->_layer_buffers.push_back(Eigen::MatrixXf(channels, LAYER_ARRAY_BUFFER_SIZE + receptiveField - 1));
this->_layer_buffers[i].setZero();
}
this->_buffer_start = this->_get_receptive_field() - 1;
Expand Down

0 comments on commit 86a9ca4

Please sign in to comment.