Skip to content

EBGAN.py give error raise TypeError('iteration over a 0-d tensor') TypeError: iteration over a 0-d tensor #10

Open

Description

@pankajbadatia

if list(self.margin-D_fake_err.data)[0] > 0: D_loss = D_real_err + (self.margin - D_fake_err) else: D_loss = D_real_err self.train_hist['D_loss'].append(D_loss.data[0])

The error is in the above line no 190 .... Below Code worked for me .. am i Correct ? I removed word list and [0]
if (self.margin-D_fake_err.data) > 0: D_loss = D_real_err + (self.margin - D_fake_err) else: D_loss = D_real_err self.train_hist['D_loss'].append(D_loss.data[0])

Activity

  1. jmmcd commented on May 23, 2018

    @jmmcd

    I think this is the same error I saw, due to an update in the pytorch API. The suggested change is to replace .data[0] with .data.item(). My pull request has this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions