8000 [feature request] Convert "indices" variable in "torch.utils.data.dataset.random_split" to list · Issue #9211 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[feature request] Convert "indices" variable in "torch.utils.data.dataset.random_split" to list #9211

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

Closed
floatn opened this issue Jul 6, 2018 · 3 comments
Labels
todo Not as important as medium or high priority tasks, but we will work on these.

Comments

@floatn
Copy link
floatn commented Jul 6, 2018

Issue description

random_split fills indices variable using torch.randperm function, which returns tensor. Through Subset class its values goes to Dataset.getitem. If I override getitem, tensor values are ok for indexing list, but with pandas DataFrame it raises TypeError. Maybe it would be better to convert indices to list variable at start.

Code example

df = pd.DataFrame([1, 2])
tn = torch.tensor([0, 1])
df.iloc[tn[0]]
...
...
TypeError: len() of unsized object

@fmassa
Copy link
Member
fmassa commented Jul 6, 2018

I think we can just add a .tolist() after the code in here. Could you send a PR?

@floatn
Copy link
Author
floatn commented Jul 7, 2018

Done. #9237 .

@zou3519 zou3519 added the todo Not as important as medium or high priority tasks, but we will work on these. label Jul 9, 2018
@soumith
Copy link
Member
soumith commented Jul 23, 2018

closed via the discussion in #9237

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
todo Not as important as medium or high priority tasks, but we will work on these.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
0