Fix TypeError: numpy.float64 cannot be interpreted as integer - #716
Merged
mpariente merged 1 commit intoMay 13, 2026
Merged
Conversation
Cast encoder.n_feats_out and similar values to int across all model constructors to prevent TypeError when numpy returns float64 scalars from arithmetic operations. Newer numpy versions enforce stricter integer type checking, causing nn.Conv1d, nn.Parameter, and other PyTorch layers to reject numpy.float64 where a Python int is expected. Fixes asteroid-team#713
Collaborator
|
Thank you ! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
encoder.n_feats_outand similar values toint()across all model constructors and recipe files to preventTypeError: 'numpy.float64' object cannot be interpreted as an integer.numpy.float64scalars from arithmetic operations, which PyTorch'snn.Conv1d,nn.Parameter,torch.ones(), and other APIs reject where a native Pythonintis expected.int()at the point of use, ensuring compatibility without changing any behavior.Changes
Core model files (
asteroid/models/):dprnn_tasnet.py:n_feats = int(encoder.n_feats_out)conv_tasnet.py:n_feats = int(encoder.n_feats_out)dptnet.py:n_feats = int(encoder.n_feats_out)lstm_tasnet.py:n_feats = int(encoder.n_feats_out)sudormrf.py:n_feats = int(enc.n_feats_out)(bothSuDORMRFNetandSuDORMRFImprovedNet)demask.py:n_feats_out = int(encoder.n_feats_out)before passing to helper methodsdccrnet.py:int(stft_n_filters) // 2x_umx.py:int(in_chan) // 2 + 1Mask network (
asteroid/masknn/):recurrent.py:int(np.prod(last_encoder_out_shape))inDCCRMaskNetRecipe/example files (
egs/):dns_challenge_INTERSPEECH2020/baseline/model.py:output_size = int(stft.n_feats_out)wsj0-mix/DeepClustering/model.py:int(enc.n_feats_out) // 2Test plan
DPRNNTasNet(n_src=2)construction) no longer raisesTypeErrorn_feats_outis already a Pythonintn_feats_outacross the codebase for completeness