Skip to content

Conversation

jamarshon
Copy link
Contributor

@jamarshon jamarshon commented Aug 19, 2019

In the issue #245, it was determined that for MelSpectrogram the transform already knows how many bins the stft will have and thus can initialize the fb matrix without needing to infer the dimensions of its first input.
The benefit of initializing the fb matrix immediately as opposed to lazy load when given a first input is that loading and saving from state dict (load_state_dict) will not throw an error as the tensor sizes match

@jamarshon jamarshon requested a review from vincentqb August 19, 2019 20:16
pad=self.pad, window_fn=window_fn, power=2,
normalized=False, wkwargs=wkwargs)
self.mel_scale = MelScale(self.n_mels, self.sample_rate, self.f_min, self.f_max)
self.mel_scale = MelScale(self.n_mels, self.sample_rate, self.f_min, self.f_max, self.n_fft // 2 + 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to read off the size of the spectrogram instead of recomputing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not unless the spectrogram computes a specgram and we look at the tensor's dimension

Copy link
Contributor

@vincentqb vincentqb Aug 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that constant n_fft // 2 + 1 is used in a few places within Spectrogram, we could attach it to Spectrogram. If that's our inferred default dimension, we could also just attach a default_dimension to Spectrogram, in case that ever changes, but that would add clutter to the Spectrogram interface.

Alright, I'm ok with having the value recomputed here. If there's ever a change in this, the test will fail :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants