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

Type error #1

Open
gamingsciences opened this issue Jun 29, 2019 · 2 comments
Open

Type error #1

gamingsciences opened this issue Jun 29, 2019 · 2 comments

Comments

@gamingsciences
Copy link

Received the following error in cell 6 of the demo.ipynb:


RuntimeError Traceback (most recent call last)
in
----> 1 model.fit(X_train, epochs=1000, val=X_val)

C:\Program Files\Anaconda3\envs\my-fastai2019\lib\site-packages\dfencoder\autoencoder.py in fit(self, df, epochs, val)
566 msg = "Validating during training.\n"
567 msg += "Computing baseline performance..."
--> 568 baseline = self.compute_baseline_performance(val_in, val_df)
569 if self.verbose:
570 print(msg)

C:\Program Files\Anaconda3\envs\my-fastai2019\lib\site-packages\dfencoder\autoencoder.py in compute_baseline_performance(self, in_, out_)
540 feature = list(self.categorical_fts.items())[i][1]
541 dim = len(feature['cats']) + 1
--> 542 pred = ohe(cd, dim, device=self.device) * 5
543 codes_pred.append(pred)
544 mse_loss, bce_loss, cce_loss, net_loss = self.compute_loss(

C:\Program Files\Anaconda3\envs\my-fastai2019\lib\site-packages\dfencoder\autoencoder.py in ohe(input_vector, dim, device)
21
22 y_onehot.zero_()
---> 23 y_onehot.scatter_(1, y, 1)
24
25 return y_onehot

RuntimeError: Expected object of scalar type Long but got scalar type Int for argument #3 'index'

@AlliedToasters
Copy link
Owner

Hello,

Sorry for the late reply. I suppose I will need more information about your system/install to reproduce the error - I do not get this outcome when I run the demo notebook on my system.

@giahung24
Copy link

Hello,

I had the same error on Windows 10 64bit intel i7.
I just applied a hot fix by changing the dtype of code in the function compute_targets

code = torch.tensor(df[ft].cat.codes.astype(int).values, dtype=torch.int64).to(self.device)

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

3 participants