Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: Could not infer dtype of numpy.int16 #928

Open
Qingkali opened this issue Dec 13, 2024 · 1 comment
Open

RuntimeError: Could not infer dtype of numpy.int16 #928

Qingkali opened this issue Dec 13, 2024 · 1 comment

Comments

@Qingkali
Copy link

When I attempted to use the TSC function,dls = TSDataLoaders.from_dsets(dsets.train, dsets.valid, bs=[64, 128], batch_tfms=[TSStandardize()], num_workers=0) I encountered some errors(RuntimeError: Could not infer dtype of numpy.int16)."This question has troubled me for a long time. Have you solved it

@saidineshpola
Copy link

saidineshpola commented Dec 13, 2024

I'm also getting this I'm tired of asking claude and came here for solution.

I have to do multi-label classification for each target in 95 labels so output is 95 length of array having elements 0,1

import numpy as np

# Explicitly convert TrainX and trainy to float32
TrainX = np.array(TrainX, dtype=np.float32)
trainy = np.array(trainy, dtype=np.float32)  # or np.int64 if it's a classification problem

# Verify the dtypes and `shapes`
print("TrainX dtype:", TrainX.dtype) # TrainX dtype: float32
print("trainy dtype:", trainy.dtype) # trainy dtype: float32
print("TrainX shape:", TrainX.shape) # TrainX shape: (31839, 1, 85922)
print("trainy shape:", trainy.shape) # trainy shape: (31839, 94)

# Create data loaders with explicit type handling
tfms = [None]  # or [TSMultiLabelClassification()] depending on your exact needs
batch_tfms = TSStandardize()
dls = get_ts_dls(TrainX, trainy, splits=splits, tfms=tfms, batch_tfms=batch_tfms, bs=[64, 128])

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

No branches or pull requests

2 participants