Skip to content

Fix TypeError: numpy.float64 cannot be interpreted as integer - #716

Merged
mpariente merged 1 commit into
asteroid-team:masterfrom
deekshaNVIDIA:fix/numpy-float64-integer-cast
May 13, 2026
Merged

Fix TypeError: numpy.float64 cannot be interpreted as integer#716
mpariente merged 1 commit into
asteroid-team:masterfrom
deekshaNVIDIA:fix/numpy-float64-integer-cast

Conversation

@deekshaNVIDIA

Copy link
Copy Markdown
Contributor

Summary

  • Fixes TypeError: 'numpy.float64' object cannot be interpreted as an integer #713: Cast encoder.n_feats_out and similar values to int() across all model constructors and recipe files to prevent TypeError: 'numpy.float64' object cannot be interpreted as an integer.
  • Newer NumPy versions return numpy.float64 scalars from arithmetic operations, which PyTorch's nn.Conv1d, nn.Parameter, torch.ones(), and other APIs reject where a native Python int is expected.
  • This is a minimal, targeted fix that wraps the filterbank output channel count with 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) (both SuDORMRFNet and SuDORMRFImprovedNet)
  • demask.py: n_feats_out = int(encoder.n_feats_out) before passing to helper methods
  • dccrnet.py: int(stft_n_filters) // 2
  • x_umx.py: int(in_chan) // 2 + 1

Mask network (asteroid/masknn/):

  • recurrent.py: int(np.prod(last_encoder_out_shape)) in DCCRMaskNet

Recipe/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) // 2

Test plan

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
@mpariente

Copy link
Copy Markdown
Collaborator

Thank you !

@mpariente
mpariente merged commit fce8746 into asteroid-team:master May 13, 2026
1 of 4 checks passed
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.

TypeError: 'numpy.float64' object cannot be interpreted as an integer

2 participants