{
  "id": 200825,
  "title": "Predicting test data without labels",
  "url": "/competitions/digit-recognizer/discussion/200825",
  "author_name": "Kanmani Imaya",
  "post_date": "2020-12-02T02:42:46.524000",
  "votes": 1,
  "comment_count": 0,
  "views": null,
  "content": "<p>Hi,<br>\nCould someone explain how to predict test data that has no targets? In Keras, it seems that there is something like predict_classes() function. I'm using pytorch and wondering how to do that. Here is my code and it throws me an error: \"argument 'input' (position 1) must be Tensor, not list\"</p>\n<p>When I tried to convert inputs into a tensor, it throws me another error.</p>\n<p>test_loader = DataLoader(test_dataset, batch_size=64)</p>\n<p>def evaluate(model, test_loader):<br>\n    with torch.no_grad():<br>\n        model.eval()<br>\n        for batch in test_loader:<br>\n            inputs = batch<br>\n            output = model(inputs)<br>\n            _, predicted = torch.max(output, 1)<br>\n            predicted = predicted.numpy()<br>\n        return predicted</p>",
  "messages": [
    {
      "id": 1099009,
      "postDate": "2020-12-02T02:42:46.523Z",
      "content": "<p>Hi,<br>\nCould someone explain how to predict test data that has no targets? In Keras, it seems that there is something like predict_classes() function. I'm using pytorch and wondering how to do that. Here is my code and it throws me an error: \"argument 'input' (position 1) must be Tensor, not list\"</p>\n<p>When I tried to convert inputs into a tensor, it throws me another error.</p>\n<p>test_loader = DataLoader(test_dataset, batch_size=64)</p>\n<p>def evaluate(model, test_loader):<br>\n    with torch.no_grad():<br>\n        model.eval()<br>\n        for batch in test_loader:<br>\n            inputs = batch<br>\n            output = model(inputs)<br>\n            _, predicted = torch.max(output, 1)<br>\n            predicted = predicted.numpy()<br>\n        return predicted</p>",
      "rawMarkdown": "Hi,\nCould someone explain how to predict test data that has no targets? In Keras, it seems that there is something like predict_classes() function. I'm using pytorch and wondering how to do that. Here is my code and it throws me an error: \"argument 'input' (position 1) must be Tensor, not list\"\n\nWhen I tried to convert inputs into a tensor, it throws me another error.\n\ntest_loader = DataLoader(test_dataset, batch_size=64)\n\ndef evaluate(model, test_loader):\n    with torch.no_grad():\n        model.eval()\n        for batch in test_loader:\n            inputs = batch\n            output = model(inputs)\n            _, predicted = torch.max(output, 1)\n            predicted = predicted.numpy()\n        return predicted\n",
      "votes": 1
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "1099009": "Hi,\nCould someone explain how to predict test data that has no targets? In Keras, it seems that there is something like predict_classes() function. I'm using pytorch and wondering how to do that. Here is my code and it throws me an error: \"argument 'input' (position 1) must be Tensor, not list\"\n\nWhen I tried to convert inputs into a tensor, it throws me another error.\n\ntest_loader = DataLoader(test_dataset, batch_size=64)\n\ndef evaluate(model, test_loader):\n    with torch.no_grad():\n        model.eval()\n        for batch in test_loader:\n            inputs = batch\n            output = model(inputs)\n            _, predicted = torch.max(output, 1)\n            predicted = predicted.numpy()\n        return predicted\n"
  }
}