[GH-ISSUE #194] error in 10_Utilities #7297

Closed
opened 2026-07-11 11:17:54 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @kumar-mahendra on GitHub (Sep 1, 2021).
Original GitHub issue: https://github.com/GokuMohandas/Made-With-ML/issues/194

class Dataset 's method collate_fn needs a little change as otherwise following error in thrown when creating dataloader

ValueError: setting an array element with a sequence

Given Code

"""Processing on a batch."""
    # Get inputs
    batch = np.array(batch, dtype=object)
    X = batch[:, 0]    # This line execution throws above error 
    y = np.stack(batch[:, 1], axis=0)

Suggested solution

"""Processing on a batch."""
    # Get inputs
    batch = np.array(batch, dtype=object)
    X = np.stack(batch[:, 0] ,axis=0) 
    y = np.stack(batch[:, 1], axis=0)
```

Originally created by @kumar-mahendra on GitHub (Sep 1, 2021). Original GitHub issue: https://github.com/GokuMohandas/Made-With-ML/issues/194 class `Dataset` 's method `collate_fn` needs a little change as otherwise following error in thrown when creating dataloader `ValueError: setting an array element with a sequence` Given Code ``` """Processing on a batch.""" # Get inputs batch = np.array(batch, dtype=object) X = batch[:, 0] # This line execution throws above error y = np.stack(batch[:, 1], axis=0) ``` Suggested solution ```` """Processing on a batch.""" # Get inputs batch = np.array(batch, dtype=object) X = np.stack(batch[:, 0] ,axis=0) y = np.stack(batch[:, 1], axis=0) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/Made-With-ML#7297