Anurag1734/cuda-error-resolution-analysis
07
1[2 {3 "post_stream": {4 "posts": [5 {6 "id": 353430,7 "name": "Patrick Ferreira",8 "username": "patrickctrf",9 "avatar_template": "/user_avatar/discuss.pytorch.org/patrickctrf/{size}/30332_2.png",10 "created_at": "2022-06-25T22:52:05.016Z",11 "cooked": "<p>I’m debugging my GAN training script because my generator does not learn anything. I’m using a Subset of my dataset with a single sample, so my generator should learn a constant output equal to that sample. But it doesn’t.</p>\n<pre><code class=\"lang-auto\"># Train Data\ntrain_dataset = NsynthDatasetFourier(path=\"nsynth-train/\", noise_length=noise_length)\ntrain_dataset = Subset(train_dataset, [0, ]) # dummy dataset for testing script\ntrain_dataloader = DataLoader(train_dataset, batch_size=batch_size, shuffle=True, num_workers=1)\n</code></pre>\n<hr>\n<p>Then I decided to create a <code>dummy_generator</code> that only outputs a <strong>Parameter Tensor</strong> saved as instance object. So it definitely should learn that tensor to be equal to the only sample um my dataset, but that tensor never changes.</p>\n<pre><code class=\"lang-auto\">class DummyGenerator(nn.Module):\n def __init__(self, *args, **kwargs):\n super().__init__()\n\n self.dummy_tensor = nn.Parameter(torch.rand((1, 2, 1024, 128), requires_grad=True))\n\n def forward(self, x):\n return self.dummy_tensor\n</code></pre>\n<hr>\n<p>Is my approach correct? Neither my original Generator or my DummyGenerator seems to learn, no matter how big is my learning rate. My discriminator seems to learn fine.</p>\n<p><strong>If anybody can help me, I would be very grateful. My complete code is <a href=\"https://github.com/patrickctrf/projeto-ia376/tree/e3ptk/tests\" rel=\"noopener nofollow ugc\">here</a>.</strong></p>\n<hr>\n<p>P.S.: It is necessary to download <a href=\"http://download.magenta.tensorflow.org/datasets/nsynth/nsynth-train.jsonwav.tar.gz\" rel=\"noopener nofollow ugc\">Nsynth dataset</a> to run the complete code.</p>",12 "post_number": 1,13 "post_type": 1,14 "posts_count": 3,15 "updated_at": "2022-06-25T22:58:42.428Z",16 "reply_count": 0,17 "reply_to_post_number": null,18 "quote_count": 0,19 "incoming_link_count": 511,20 "reads": 14,21 "readers_count": 13,22 "score": 2552.8,23 "yours": false,24 "topic_id": 155064,25 "topic_slug": "cant-optimize-single-parameter-tensor",26 "display_username": "Patrick Ferreira",27 "primary_group_name": null,28 "flair_name": null,29 "flair_url": null,30 "flair_bg_color": null,31 "flair_color": null,32 "flair_group_id": null,33 "badges_granted": [],34 "version": 2,35 "can_edit": false,36 "can_delete": false,37 "can_recover": false,38 "can_see_hidden_post": false,39 "can_wiki": false,40 "link_counts": [41 {42 "url": "https://github.com/patrickctrf/projeto-ia376/tree/e3ptk/tests",43 "internal": false,44 "reflection": false,45 "title": "projeto-ia376/tests at e3ptk · patrickctrf/projeto-ia376 · GitHub",46 "clicks": 047 },48 {49 "url": "http://download.magenta.tensorflow.org/datasets/nsynth/nsynth-train.jsonwav.tar.gz",50 "internal": false,51 "reflection": false,52 "clicks": 053 }54 ],55 "read": true,56 "user_title": null,57 "bookmarked": false,58 "actions_summary": [],59 "moderator": false,60 "admin": false,61 "staff": false,62 "user_id": 38231,63 "hidden": false,64 "trust_level": 1,65 "deleted_at": null,66 "user_deleted": false,67 "edit_reason": null,68 "can_view_edit_history": true,69 "wiki": false,70 "post_url": "/t/cant-optimize-single-parameter-tensor/155064/1",71 "can_accept_answer": false,72 "can_unaccept_answer": false,73 "accepted_answer": false,74 "topic_accepted_answer": null,75 "can_vote": false76 },77 {78 "id": 353450,79 "name": "",80 "username": "ptrblck",81 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",82 "created_at": "2022-06-26T00:53:37.096Z",83 "cooked": "<p>The use case is a bit strange, but should generally work as seen in this small example overfitting a static target:</p>\n<pre><code class=\"lang-python\">class DummyGenerator(nn.Module):\n def __init__(self, *args, **kwargs):\n super().__init__()\n\n self.dummy_tensor = nn.Parameter(torch.rand((1, 2, 1024, 128), requires_grad=True))\n\n def forward(self):\n return self.dummy_tensor\n \nmodel = DummyGenerator()\noptimizer = torch.optim.Adam(model.parameters(), lr=1e-3)\ncriterion = nn.MSELoss()\n\ny = torch.randn(1, 2, 1024, 128)\n\nfor epoch in range(10000):\n optimizer.zero_grad()\n out = model()\n loss = criterion(out, y)\n loss.backward()\n optimizer.step()\n print('epoch {}, loss {}'.format(epoch, loss.item()))\n\n# ...\n# epoch 9998, loss 1.416539715387577e-11\n# epoch 9999, loss 1.4069788736859046e-11\n</code></pre>\n<p>Check if your parameter has a valid <code>.grad</code> attribute after the <code>backward</code> call and is indeed being updated.</p>",84 "post_number": 2,85 "post_type": 1,86 "posts_count": 3,87 "updated_at": "2022-06-26T00:53:37.096Z",88 "reply_count": 1,89 "reply_to_post_number": null,90 "quote_count": 0,91 "incoming_link_count": 23,92 "reads": 12,93 "readers_count": 11,94 "score": 122.4,95 "yours": false,96 "topic_id": 155064,97 "topic_slug": "cant-optimize-single-parameter-tensor",98 "display_username": "",99 "primary_group_name": null,100 "flair_name": null,101 "flair_url": null,102 "flair_bg_color": null,103 "flair_color": null,104 "flair_group_id": null,105 "badges_granted": [],106 "version": 1,107 "can_edit": false,108 "can_delete": false,109 "can_recover": false,110 "can_see_hidden_post": false,111 "can_wiki": false,112 "read": true,113 "user_title": "",114 "bookmarked": false,115 "actions_summary": [],116 "moderator": true,117 "admin": true,118 "staff": true,119 "user_id": 3534,120 "hidden": false,121 "trust_level": 2,122 "deleted_at": null,123 "user_deleted": false,124 "edit_reason": null,125 "can_view_edit_history": true,126 "wiki": false,127 "post_url": "/t/cant-optimize-single-parameter-tensor/155064/2",128 "can_accept_answer": false,129 "can_unaccept_answer": false,130 "accepted_answer": false,131 "topic_accepted_answer": null132 },133 {134 "id": 353537,135 "name": "Patrick Ferreira",136 "username": "patrickctrf",137 "avatar_template": "/user_avatar/discuss.pytorch.org/patrickctrf/{size}/30332_2.png",138 "created_at": "2022-06-26T21:19:46.921Z",139 "cooked": "<p>Thanks for your response. I tried a case similar to your example and changed my generator <strong>loss</strong> to minimize the difference from the <strong>target</strong>, instead of aiming discriminator’s output:</p>\n<pre><code class=\"lang-auto\">generator_discriminator_out = discriminator(generated_data)\ngenerator_loss = criterion(generated_data, target)\n# generator_loss = criterion(generator_discriminator_out, true_labels)\n</code></pre>\n<p>The generator successfully accomplishes this task and the discriminator’s output becomes 0.5 for every input (this is expected).</p>\n<hr>\n<p>But when I go back to the original loss for GANs (trying to be approved by the discriminator), the output from my generator doesn’t match the sample:</p>\n<pre><code class=\"lang-auto\">generator_discriminator_out = discriminator(generated_data)\n# generator_loss = criterion(generated_data, target)\ngenerator_loss = criterion(generator_discriminator_out, true_labels)\n</code></pre>\n<hr>\n<p>This is an indicator that the discrimination is not learning the correct target, right?</p>\n<p>Extra info: When I train with the <strong>whole dataset</strong> again, generator gets stuck with <strong>constant output</strong> for every input (and MSE loss goes to 1, the maximum value). I don’t know if it’s relevant information, but I don’t understand why my generator would stop in bad local minima like that.</p>",140 "post_number": 3,141 "post_type": 1,142 "posts_count": 3,143 "updated_at": "2022-06-26T21:19:46.921Z",144 "reply_count": 0,145 "reply_to_post_number": 2,146 "quote_count": 0,147 "incoming_link_count": 4,148 "reads": 10,149 "readers_count": 9,150 "score": 22.0,151 "yours": false,152 "topic_id": 155064,153 "topic_slug": "cant-optimize-single-parameter-tensor",154 "display_username": "Patrick Ferreira",155 "primary_group_name": null,156 "flair_name": null,157 "flair_url": null,158 "flair_bg_color": null,159 "flair_color": null,160 "flair_group_id": null,161 "badges_granted": [],162 "version": 1,163 "can_edit": false,164 "can_delete": false,165 "can_recover": false,166 "can_see_hidden_post": false,167 "can_wiki": false,168 "read": true,169 "user_title": null,170 "reply_to_user": {171 "id": 3534,172 "username": "ptrblck",173 "name": "",174 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png"175 },176 "bookmarked": false,177 "actions_summary": [],178 "moderator": false,179 "admin": false,180 "staff": false,181 "user_id": 38231,182 "hidden": false,183 "trust_level": 1,184 "deleted_at": null,185 "user_deleted": false,186 "edit_reason": null,187 "can_view_edit_history": true,188 "wiki": false,189 "post_url": "/t/cant-optimize-single-parameter-tensor/155064/3",190 "can_accept_answer": false,191 "can_unaccept_answer": false,192 "accepted_answer": false,193 "topic_accepted_answer": null194 }195 ],196 "stream": [197 353430,198 353450,199 353537200 ]201 },202 "timeline_lookup": [203 [204 1,205 1218206 ],207 [208 3,209 1217210 ]211 ],212 "suggested_topics": [213 {214 "fancy_title": "Permute inside nn.Sequential",215 "id": 214877,216 "title": "Permute inside nn.Sequential",217 "slug": "permute-inside-nn-sequential",218 "posts_count": 3,219 "reply_count": 0,220 "highest_post_number": 3,221 "image_url": null,222 "created_at": "2025-01-02T08:19:47.254Z",223 "last_posted_at": "2025-09-15T19:19:55.247Z",224 "bumped": true,225 "bumped_at": "2025-09-15T19:19:55.247Z",226 "archetype": "regular",227 "unseen": false,228 "pinned": false,229 "unpinned": null,230 "visible": true,231 "closed": false,232 "archived": false,233 "bookmarked": null,234 "liked": null,235 "tags_descriptions": {},236 "like_count": 1,237 "views": 476,238 "category_id": 1,239 "featured_link": null,240 "has_accepted_answer": false,241 "posters": [242 {243 "extras": null,244 "description": "Original Poster",245 "user": {246 "id": 81597,247 "username": "nada",248 "name": null,249 "avatar_template": "/letter_avatar_proxy/v4/letter/n/a88e4f/{size}.png",250 "trust_level": 1251 }252 },253 {254 "extras": null,255 "description": "Frequent Poster",256 "user": {257 "id": 3534,258 "username": "ptrblck",259 "name": "",260 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",261 "admin": true,262 "moderator": true,263 "trust_level": 2264 }265 },266 {267 "extras": "latest",268 "description": "Most Recent Poster",269 "user": {270 "id": 32812,271 "username": "Bjorn_Lindqvist",272 "name": "Björn Lindqvist",273 "avatar_template": "/user_avatar/discuss.pytorch.org/bjorn_lindqvist/{size}/25326_2.png",274 "trust_level": 2275 }276 }277 ]278 },279 {280 "fancy_title": "Error in official document code?",281 "id": 216146,282 "title": "Error in official document code?",283 "slug": "error-in-official-document-code",284 "posts_count": 4,285 "reply_count": 2,286 "highest_post_number": 4,287 "image_url": null,288 "created_at": "2025-02-02T09:21:45.638Z",289 "last_posted_at": "2025-02-03T01:44:55.859Z",290 "bumped": true,291 "bumped_at": "2025-02-03T01:44:55.859Z",292 "archetype": "regular",293 "unseen": false,294 "pinned": false,295 "unpinned": null,296 "visible": true,297 "closed": false,298 "archived": false,299 "bookmarked": null,300 "liked": null,301 "tags_descriptions": {},302 "like_count": 0,303 "views": 147,304 "category_id": 1,305 "featured_link": null,306 "has_accepted_answer": true,307 "posters": [308 {309 "extras": null,310 "description": "Original Poster",311 "user": {312 "id": 66124,313 "username": "Aakira",314 "name": "Aakira",315 "avatar_template": "/user_avatar/discuss.pytorch.org/aakira/{size}/58984_2.png",316 "trust_level": 1317 }318 },319 {320 "extras": "latest",321 "description": "Most Recent Poster, Accepted Answer",322 "user": {323 "id": 18088,324 "username": "KFrank",325 "name": "K. Frank",326 "avatar_template": "/letter_avatar_proxy/v4/letter/k/ecb155/{size}.png",327 "trust_level": 2328 }329 }330 ]331 },332 {333 "fancy_title": "torch.export.ExportedProgram",334 "id": 217502,335 "title": "torch.export.ExportedProgram",336 "slug": "torch-export-exportedprogram",337 "posts_count": 1,338 "reply_count": 0,339 "highest_post_number": 1,340 "image_url": null,341 "created_at": "2025-03-06T04:54:17.482Z",342 "last_posted_at": "2025-03-06T04:54:17.519Z",343 "bumped": true,344 "bumped_at": "2025-03-06T04:54:17.519Z",345 "archetype": "regular",346 "unseen": false,347 "pinned": false,348 "unpinned": null,349 "visible": true,350 "closed": false,351 "archived": false,352 "bookmarked": null,353 "liked": null,354 "tags_descriptions": {},355 "like_count": 0,356 "views": 58,357 "category_id": 1,358 "featured_link": null,359 "has_accepted_answer": false,360 "posters": [361 {362 "extras": "latest single",363 "description": "Original Poster, Most Recent Poster",364 "user": {365 "id": 83097,366 "username": "qianfenchi",367 "name": "qianfenchi",368 "avatar_template": "/user_avatar/discuss.pytorch.org/qianfenchi/{size}/76008_2.png",369 "trust_level": 0370 }371 }372 ]373 },374 {375 "fancy_title": "Multithreading in dataloader workers",376 "id": 215391,377 "title": "Multithreading in dataloader workers",378 "slug": "multithreading-in-dataloader-workers",379 "posts_count": 1,380 "reply_count": 0,381 "highest_post_number": 1,382 "image_url": null,383 "created_at": "2025-01-14T19:37:36.279Z",384 "last_posted_at": "2025-01-14T19:37:36.321Z",385 "bumped": true,386 "bumped_at": "2025-01-14T19:51:42.020Z",387 "archetype": "regular",388 "unseen": false,389 "pinned": false,390 "unpinned": null,391 "visible": true,392 "closed": false,393 "archived": false,394 "bookmarked": null,395 "liked": null,396 "tags_descriptions": {},397 "like_count": 0,398 "views": 123,399 "category_id": 1,400 "featured_link": null,401 "has_accepted_answer": false,402 "posters": [403 {404 "extras": "latest single",405 "description": "Original Poster, Most Recent Poster",406 "user": {407 "id": 71847,408 "username": "Tristan_Brugere",409 "name": "Tristan Brugere",410 "avatar_template": "/user_avatar/discuss.pytorch.org/tristan_brugere/{size}/66365_2.png",411 "trust_level": 1412 }413 }414 ]415 },416 {417 "fancy_title": "Help with training performances",418 "id": 218181,419 "title": "Help with training performances",420 "slug": "help-with-training-performances",421 "posts_count": 3,422 "reply_count": 0,423 "highest_post_number": 3,424 "image_url": null,425 "created_at": "2025-03-23T18:46:00.470Z",426 "last_posted_at": "2025-07-22T16:00:36.568Z",427 "bumped": true,428 "bumped_at": "2025-07-22T16:00:36.568Z",429 "archetype": "regular",430 "unseen": false,431 "pinned": false,432 "unpinned": null,433 "visible": true,434 "closed": false,435 "archived": false,436 "bookmarked": null,437 "liked": null,438 "tags_descriptions": {},439 "like_count": 0,440 "views": 156,441 "category_id": 1,442 "featured_link": null,443 "has_accepted_answer": false,444 "posters": [445 {446 "extras": null,447 "description": "Original Poster",448 "user": {449 "id": 83431,450 "username": "Luigi_Scilimati",451 "name": "Luigi Scilimati",452 "avatar_template": "/user_avatar/discuss.pytorch.org/luigi_scilimati/{size}/73123_2.png",453 "trust_level": 0454 }455 },456 {457 "extras": null,458 "description": "Frequent Poster",459 "user": {460 "id": 3534,461 "username": "ptrblck",462 "name": "",463 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",464 "admin": true,465 "moderator": true,466 "trust_level": 2467 }468 },469 {470 "extras": "latest",471 "description": "Most Recent Poster",472 "user": {473 "id": 85189,474 "username": "CodingWookie",475 "name": "Coding Wookie",476 "avatar_template": "/user_avatar/discuss.pytorch.org/codingwookie/{size}/77756_2.png",477 "trust_level": 1478 }479 }480 ]481 }482 ],483 "tags_descriptions": {},484 "fancy_title": "Can’t optimize single parameter Tensor",485 "id": 155064,486 "title": "Can't optimize single parameter Tensor",487 "posts_count": 3,488 "created_at": "2022-06-25T22:52:04.917Z",489 "views": 1000,490 "reply_count": 1,491 "like_count": 0,492 "last_posted_at": "2022-06-26T21:19:46.921Z",493 "visible": true,494 "closed": false,495 "archived": false,496 "has_summary": false,497 "archetype": "regular",498 "slug": "cant-optimize-single-parameter-tensor",499 "category_id": 1,500 "word_count": 509,501 "deleted_at": null,502 "user_id": 38231,503 "featured_link": null,504 "pinned_globally": false,505 "pinned_at": null,506 "pinned_until": null,507 "image_url": null,508 "slow_mode_seconds": 0,509 "draft": null,510 "draft_key": "topic_155064",511 "draft_sequence": null,512 "unpinned": null,513 "pinned": false,514 "current_post_number": 1,515 "highest_post_number": 3,516 "deleted_by": null,517 "actions_summary": [518 {519 "id": 4,520 "count": 0,521 "hidden": false,522 "can_act": false523 },524 {525 "id": 8,526 "count": 0,527 "hidden": false,528 "can_act": false529 },530 {531 "id": 10,532 "count": 0,533 "hidden": false,534 "can_act": false535 },536 {537 "id": 7,538 "count": 0,539 "hidden": false,540 "can_act": false541 }542 ],543 "chunk_size": 20,544 "bookmarked": false,545 "topic_timer": null,546 "message_bus_last_id": 0,547 "participant_count": 2,548 "show_read_indicator": false,549 "thumbnails": null,550 "slow_mode_enabled_until": null,551 "can_vote": false,552 "vote_count": 0,553 "user_voted": false,554 "discourse_zendesk_plugin_zendesk_id": null,555 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",556 "details": {557 "can_edit": false,558 "notification_level": 1,559 "participants": [560 {561 "id": 38231,562 "username": "patrickctrf",563 "name": "Patrick Ferreira",564 "avatar_template": "/user_avatar/discuss.pytorch.org/patrickctrf/{size}/30332_2.png",565 "post_count": 2,566 "primary_group_name": null,567 "flair_name": null,568 "flair_url": null,569 "flair_color": null,570 "flair_bg_color": null,571 "flair_group_id": null,572 "trust_level": 1573 },574 {575 "id": 3534,576 "username": "ptrblck",577 "name": "",578 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",579 "post_count": 1,580 "primary_group_name": null,581 "flair_name": null,582 "flair_url": null,583 "flair_color": null,584 "flair_bg_color": null,585 "flair_group_id": null,586 "admin": true,587 "moderator": true,588 "trust_level": 2589 }590 ],591 "created_by": {592 "id": 38231,593 "username": "patrickctrf",594 "name": "Patrick Ferreira",595 "avatar_template": "/user_avatar/discuss.pytorch.org/patrickctrf/{size}/30332_2.png"596 },597 "last_poster": {598 "id": 38231,599 "username": "patrickctrf",600 "name": "Patrick Ferreira",601 "avatar_template": "/user_avatar/discuss.pytorch.org/patrickctrf/{size}/30332_2.png"602 }603 },604 "bookmarks": []605 },606 {607 "post_stream": {608 "posts": [609 {610 "id": 353533,611 "name": "iamexperimenting",612 "username": "iamexperimentingnow",613 "avatar_template": "/user_avatar/discuss.pytorch.org/iamexperimentingnow/{size}/43455_2.png",614 "created_at": "2022-06-26T20:29:32.466Z",615 "cooked": "<p>I’m trying to save my model in TorchScript format, but unfortunately getting errors.</p>\n<h2><a name=\"what-you-have-already-tried-1\" class=\"anchor\" href=\"#what-you-have-already-tried-1\"></a>What you have already tried</h2>\n<p><code>torch.jit.script(model)</code></p>\n<h2><a name=\"environment-2\" class=\"anchor\" href=\"#environment-2\"></a>Environment</h2>\n<p>python</p>\n<blockquote>\n<p>Build information about Torch-TensorRT can be found by turning on debug messages</p>\n</blockquote>\n<ul>\n<li>PyTorch Version (e.g., 1.0):1.11.0+cu113</li>\n<li>CPU Architecture:</li>\n<li>OS (e.g., Linux): ubuntu 20.04</li>\n<li>How you installed PyTorch (<code>conda</code>, <code>pip</code>, <code>libtorch</code>, source): pip</li>\n<li>Build command you used (if compiling from source):</li>\n<li>Are you using local sources or building from archives:</li>\n<li>Python version:3.9.7</li>\n<li>CUDA version:11.7</li>\n<li>GPU models and configuration: RTX GEFORCE 2060</li>\n<li>Any other relevant information:</li>\n</ul>\n<p><div class=\"lightbox-wrapper\"><a class=\"lightbox\" href=\"https://discuss.pytorch.org/uploads/default/original/3X/7/e/7e264f0357986feccf6427a8d2a8b6f06959129e.png\" data-download-href=\"https://discuss.pytorch.org/uploads/default/7e264f0357986feccf6427a8d2a8b6f06959129e\" title=\"image\"><img src=\"https://discuss.pytorch.org/uploads/default/optimized/3X/7/e/7e264f0357986feccf6427a8d2a8b6f06959129e_2_690x388.png\" alt=\"image\" data-base62-sha1=\"hZYeHG74na1togHinZ3EswbNCEK\" width=\"690\" height=\"388\" srcset=\"https://discuss.pytorch.org/uploads/default/optimized/3X/7/e/7e264f0357986feccf6427a8d2a8b6f06959129e_2_690x388.png, https://discuss.pytorch.org/uploads/default/optimized/3X/7/e/7e264f0357986feccf6427a8d2a8b6f06959129e_2_1035x582.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/7/e/7e264f0357986feccf6427a8d2a8b6f06959129e_2_1380x776.png 2x\" data-dominant-color=\"3C1B32\"><div class=\"meta\"><svg class=\"fa d-icon d-icon-far-image svg-icon\" aria-hidden=\"true\"><use href=\"#far-image\"></use></svg><span class=\"filename\">image</span><span class=\"informations\">1920×1080 394 KB</span><svg class=\"fa d-icon d-icon-discourse-expand svg-icon\" aria-hidden=\"true\"><use href=\"#discourse-expand\"></use></svg></div></a></div></p>\n<h2><a name=\"to-reproduce-3\" class=\"anchor\" href=\"#to-reproduce-3\"></a>To Reproduce</h2>\n<p>please find the original git repo. Here, I’m using <code>ade20k-hrnetv2.yaml</code> config file.</p><aside class=\"onebox allowlistedgeneric\" data-onebox-src=\"https://github.com/CSAILVision/semantic-segmentation-pytorch\">\n <header class=\"source\">\n <img src=\"https://github.githubassets.com/favicons/favicon.svg\" class=\"site-icon\" width=\"32\" height=\"32\">\n\n <a href=\"https://github.com/CSAILVision/semantic-segmentation-pytorch\" target=\"_blank\" rel=\"noopener nofollow ugc\">GitHub</a>\n </header>\n\n <article class=\"onebox-body\">\n <div class=\"aspect-image\" style=\"--aspect-ratio:690/344;\"><img src=\"https://opengraph.githubassets.com/a9cdfa5321964e5c753904082779fcc13a4897f613b47a0e61ed34d6bbaf53ac/CSAILVision/semantic-segmentation-pytorch\" class=\"thumbnail\" width=\"690\" height=\"345\"></div>\n\n<h3><a href=\"https://github.com/CSAILVision/semantic-segmentation-pytorch\" target=\"_blank\" rel=\"noopener nofollow ugc\">GitHub - CSAILVision/semantic-segmentation-pytorch: Pytorch implementation...</a></h3>\n\n <p>Pytorch implementation for Semantic Segmentation/Scene Parsing on MIT ADE20K dataset - GitHub - CSAILVision/semantic-segmentation-pytorch: Pytorch implementation for Semantic Segmentation/Scene Par...</p>\n\n\n </article>\n\n <div class=\"onebox-metadata\">\n \n \n </div>\n\n <div style=\"clear: both\"></div>\n</aside>\n\n<p><a class=\"mention\" href=\"/u/ptrblck\">@ptrblck</a></p>",616 "post_number": 1,617 "post_type": 1,618 "posts_count": 1,619 "updated_at": "2022-06-26T20:29:32.466Z",620 "reply_count": 0,621 "reply_to_post_number": null,622 "quote_count": 0,623 "incoming_link_count": 87,624 "reads": 7,625 "readers_count": 6,626 "score": 436.4,627 "yours": false,628 "topic_id": 155114,629 "topic_slug": "unable-to-save-the-model-in-torchscript-format",630 "display_username": "iamexperimenting",631 "primary_group_name": null,632 "flair_name": null,633 "flair_url": null,634 "flair_bg_color": null,635 "flair_color": null,636 "flair_group_id": null,637 "badges_granted": [],638 "version": 1,639 "can_edit": false,640 "can_delete": false,641 "can_recover": false,642 "can_see_hidden_post": false,643 "can_wiki": false,644 "link_counts": [645 {646 "url": "https://github.com/CSAILVision/semantic-segmentation-pytorch",647 "internal": false,648 "reflection": false,649 "title": "GitHub - CSAILVision/semantic-segmentation-pytorch: Pytorch implementation for Semantic Segmentation/Scene Parsing on MIT ADE20K dataset",650 "clicks": 1651 },652 {653 "url": "https://discuss.pytorch.org/uploads/default/original/3X/7/e/7e264f0357986feccf6427a8d2a8b6f06959129e.png",654 "internal": true,655 "reflection": false,656 "clicks": 0657 }658 ],659 "read": true,660 "user_title": null,661 "bookmarked": false,662 "actions_summary": [],663 "moderator": false,664 "admin": false,665 "staff": false,666 "user_id": 49601,667 "hidden": false,668 "trust_level": 2,669 "deleted_at": null,670 "user_deleted": false,671 "edit_reason": null,672 "can_view_edit_history": true,673 "wiki": false,674 "post_url": "/t/unable-to-save-the-model-in-torchscript-format/155114/1",675 "can_accept_answer": false,676 "can_unaccept_answer": false,677 "accepted_answer": false,678 "topic_accepted_answer": null,679 "can_vote": false680 }681 ],682 "stream": [683 353533684 ]685 },686 "timeline_lookup": [687 [688 1,689 1217690 ]691 ],692 "suggested_topics": [693 {694 "fancy_title": "Is dynamic_dim disabled in pytorch",695 "id": 219293,696 "title": "Is dynamic_dim disabled in pytorch",697 "slug": "is-dynamic-dim-disabled-in-pytorch",698 "posts_count": 1,699 "reply_count": 0,700 "highest_post_number": 1,701 "image_url": null,702 "created_at": "2025-04-21T09:11:25.142Z",703 "last_posted_at": "2025-04-21T09:11:25.183Z",704 "bumped": true,705 "bumped_at": "2025-04-21T11:28:41.170Z",706 "archetype": "regular",707 "unseen": false,708 "pinned": false,709 "unpinned": null,710 "visible": true,711 "closed": false,712 "archived": false,713 "bookmarked": null,714 "liked": null,715 "tags_descriptions": {},716 "like_count": 0,717 "views": 63,718 "category_id": 13,719 "featured_link": null,720 "has_accepted_answer": false,721 "posters": [722 {723 "extras": "latest single",724 "description": "Original Poster, Most Recent Poster",725 "user": {726 "id": 83924,727 "username": "hmsjwzb",728 "name": null,729 "avatar_template": "/letter_avatar_proxy/v4/letter/h/48db29/{size}.png",730 "trust_level": 0731 }732 }733 ]734 },735 {736 "fancy_title": "Slow training of rCNN and torch.jit.script() function not compatible",737 "id": 214851,738 "title": "Slow training of rCNN and torch.jit.script() function not compatible",739 "slug": "slow-training-of-rcnn-and-torch-jit-script-function-not-compatible",740 "posts_count": 1,741 "reply_count": 0,742 "highest_post_number": 1,743 "image_url": null,744 "created_at": "2025-01-01T17:14:56.028Z",745 "last_posted_at": "2025-01-01T17:14:56.072Z",746 "bumped": true,747 "bumped_at": "2025-01-01T17:14:56.072Z",748 "archetype": "regular",749 "unseen": false,750 "pinned": false,751 "unpinned": null,752 "visible": true,753 "closed": false,754 "archived": false,755 "bookmarked": null,756 "liked": null,757 "tags_descriptions": {},758 "like_count": 0,759 "views": 38,760 "category_id": 13,761 "featured_link": null,762 "has_accepted_answer": false,763 "posters": [764 {765 "extras": "latest single",766 "description": "Original Poster, Most Recent Poster",767 "user": {768 "id": 81674,769 "username": "Mattis1337",770 "name": "Mattis1337",771 "avatar_template": "/user_avatar/discuss.pytorch.org/mattis1337/{size}/74690_2.png",772 "trust_level": 1773 }774 }775 ]776 },777 {778 "fancy_title": "How to check grads in each step of model?",779 "id": 216615,780 "title": "How to check grads in each step of model?",781 "slug": "how-to-check-grads-in-each-step-of-model",782 "posts_count": 2,783 "reply_count": 0,784 "highest_post_number": 2,785 "image_url": null,786 "created_at": "2025-02-13T09:04:16.004Z",787 "last_posted_at": "2025-03-24T20:39:19.668Z",788 "bumped": true,789 "bumped_at": "2025-03-24T20:39:19.668Z",790 "archetype": "regular",791 "unseen": false,792 "pinned": false,793 "unpinned": null,794 "visible": true,795 "closed": false,796 "archived": false,797 "bookmarked": null,798 "liked": null,799 "tags_descriptions": {},800 "like_count": 0,801 "views": 53,802 "category_id": 13,803 "featured_link": null,804 "has_accepted_answer": false,805 "posters": [806 {807 "extras": null,808 "description": "Original Poster",809 "user": {810 "id": 73868,811 "username": "elinliu0823",812 "name": "轶霖 柳",813 "avatar_template": "/user_avatar/discuss.pytorch.org/elinliu0823/{size}/68215_2.png",814 "trust_level": 1815 }816 },817 {818 "extras": "latest",819 "description": "Most Recent Poster",820 "user": {821 "id": 60146,822 "username": "MyCenturaHealth",823 "name": "MyCenturaHealth",824 "avatar_template": "/user_avatar/discuss.pytorch.org/mycenturahealth/{size}/46345_2.png",825 "trust_level": 1826 }827 }828 ]829 },830 {831 "fancy_title": "Torch.jit._get_trace_graph",832 "id": 219103,833 "title": "Torch.jit._get_trace_graph",834 "slug": "torch-jit-get-trace-graph",835 "posts_count": 1,836 "reply_count": 0,837 "highest_post_number": 1,838 "image_url": null,839 "created_at": "2025-04-15T11:21:23.571Z",840 "last_posted_at": "2025-04-15T11:21:23.612Z",841 "bumped": true,842 "bumped_at": "2025-04-16T05:35:42.219Z",843 "archetype": "regular",844 "unseen": false,845 "pinned": false,846 "unpinned": null,847 "visible": true,848 "closed": false,849 "archived": false,850 "bookmarked": null,851 "liked": null,852 "tags_descriptions": {},853 "like_count": 0,854 "views": 72,855 "category_id": 13,856 "featured_link": null,857 "has_accepted_answer": false,858 "posters": [859 {860 "extras": "latest single",861 "description": "Original Poster, Most Recent Poster",862 "user": {863 "id": 81709,864 "username": "QLYYLQ",865 "name": "qly",866 "avatar_template": "/user_avatar/discuss.pytorch.org/qlyylq/{size}/74718_2.png",867 "trust_level": 1868 }869 }870 ]871 },872 {873 "fancy_title": "“Unknown type name”: forward reference breaking torchscript",874 "id": 219788,875 "title": "\"Unknown type name\": forward reference breaking torchscript",876 "slug": "unknown-type-name-forward-reference-breaking-torchscript",877 "posts_count": 1,878 "reply_count": 0,879 "highest_post_number": 1,880 "image_url": null,881 "created_at": "2025-05-06T03:23:01.894Z",882 "last_posted_at": "2025-05-06T03:23:01.937Z",883 "bumped": true,884 "bumped_at": "2025-05-06T03:23:01.937Z",885 "archetype": "regular",886 "unseen": false,887 "pinned": false,888 "unpinned": null,889 "visible": true,890 "closed": false,891 "archived": false,892 "bookmarked": null,893 "liked": null,894 "tags_descriptions": {},895 "like_count": 0,896 "views": 38,897 "category_id": 13,898 "featured_link": null,899 "has_accepted_answer": false,900 "posters": [901 {902 "extras": "latest single",903 "description": "Original Poster, Most Recent Poster",904 "user": {905 "id": 48467,906 "username": "rrm39",907 "name": "",908 "avatar_template": "/user_avatar/discuss.pytorch.org/rrm39/{size}/41644_2.png",909 "trust_level": 1910 }911 }912 ]913 }914 ],915 "tags_descriptions": {},916 "fancy_title": "Unable to save the model in TorchScript format?",917 "id": 155114,918 "title": "Unable to save the model in TorchScript format?",919 "posts_count": 1,920 "created_at": "2022-06-26T20:29:32.391Z",921 "views": 555,922 "reply_count": 0,923 "like_count": 0,924 "last_posted_at": "2022-06-26T20:29:32.466Z",925 "visible": true,926 "closed": false,927 "archived": false,928 "has_summary": false,929 "archetype": "regular",930 "slug": "unable-to-save-the-model-in-torchscript-format",931 "category_id": 13,932 "word_count": 133,933 "deleted_at": null,934 "user_id": 49601,935 "featured_link": null,936 "pinned_globally": false,937 "pinned_at": null,938 "pinned_until": null,939 "image_url": "https://discuss.pytorch.org/uploads/default/optimized/3X/7/e/7e264f0357986feccf6427a8d2a8b6f06959129e_2_1024x576.png",940 "slow_mode_seconds": 0,941 "draft": null,942 "draft_key": "topic_155114",943 "draft_sequence": null,944 "unpinned": null,945 "pinned": false,946 "current_post_number": 1,947 "highest_post_number": 1,948 "deleted_by": null,949 "actions_summary": [950 {951 "id": 4,952 "count": 0,953 "hidden": false,954 "can_act": false955 },956 {957 "id": 8,958 "count": 0,959 "hidden": false,960 "can_act": false961 },962 {963 "id": 10,964 "count": 0,965 "hidden": false,966 "can_act": false967 },968 {969 "id": 7,970 "count": 0,971 "hidden": false,972 "can_act": false973 }974 ],975 "chunk_size": 20,976 "bookmarked": false,977 "topic_timer": null,978 "message_bus_last_id": 0,979 "participant_count": 1,980 "show_read_indicator": false,981 "thumbnails": [982 {983 "max_width": null,984 "max_height": null,985 "width": 1920,986 "height": 1080,987 "url": "https://discuss.pytorch.org/uploads/default/original/3X/7/e/7e264f0357986feccf6427a8d2a8b6f06959129e.png"988 },989 {990 "max_width": 1024,991 "max_height": 1024,992 "width": 1024,993 "height": 576,994 "url": "https://discuss.pytorch.org/uploads/default/optimized/3X/7/e/7e264f0357986feccf6427a8d2a8b6f06959129e_2_1024x576.png"995 }996 ],997 "slow_mode_enabled_until": null,998 "can_vote": false,999 "vote_count": 0,1000 "user_voted": false,1001 "discourse_zendesk_plugin_zendesk_id": null,1002 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",1003 "details": {1004 "can_edit": false,1005 "notification_level": 1,1006 "participants": [1007 {1008 "id": 49601,1009 "username": "iamexperimentingnow",1010 "name": "iamexperimenting",1011 "avatar_template": "/user_avatar/discuss.pytorch.org/iamexperimentingnow/{size}/43455_2.png",1012 "post_count": 1,1013 "primary_group_name": null,1014 "flair_name": null,1015 "flair_url": null,1016 "flair_color": null,1017 "flair_bg_color": null,1018 "flair_group_id": null,1019 "trust_level": 21020 }1021 ],1022 "created_by": {1023 "id": 49601,1024 "username": "iamexperimentingnow",1025 "name": "iamexperimenting",1026 "avatar_template": "/user_avatar/discuss.pytorch.org/iamexperimentingnow/{size}/43455_2.png"1027 },1028 "last_poster": {1029 "id": 49601,1030 "username": "iamexperimentingnow",1031 "name": "iamexperimenting",1032 "avatar_template": "/user_avatar/discuss.pytorch.org/iamexperimentingnow/{size}/43455_2.png"1033 },1034 "links": [1035 {1036 "url": "https://github.com/CSAILVision/semantic-segmentation-pytorch",1037 "title": "GitHub - CSAILVision/semantic-segmentation-pytorch: Pytorch implementation for Semantic Segmentation/Scene Parsing on MIT ADE20K dataset",1038 "internal": false,1039 "attachment": false,1040 "reflection": false,1041 "clicks": 1,1042 "user_id": 49601,1043 "domain": "github.com",1044 "root_domain": "github.com"1045 }1046 ]1047 },1048 "bookmarks": []1049 },1050 {1051 "post_stream": {1052 "posts": [1053 {1054 "id": 353467,1055 "name": "amit",1056 "username": "laro",1057 "avatar_template": "/user_avatar/discuss.pytorch.org/laro/{size}/47125_2.png",1058 "created_at": "2022-06-26T07:11:51.567Z",1059 "cooked": "<p>I Have the following model:</p>\n<p>import torch<br>\nimport torch.nn as nn<br>\nimport torch.nn.functional as F</p>\n<p>class MyModel(nn.Module):</p>\n<pre><code>def __init__(self, input_size, num_classes):\n super(MyModel, self).__init__()\n \n \n \n self.layer_1 = nn.Conv1d(1, 16, 3, bias=False, stride=2)\n self.activation_1 = F.relu \n self.adap = nn.AdaptiveAvgPool1d(1)\n self.flatten = nn.Flatten (), \n \n self.layer_2 = torch.nn.Linear(2249, 500)\n self.activation_2 = F.relu\n self.layer_3 = torch.nn.Linear(500, 2)\n \n \n pass\n\ndef forward(self, x, labels=None):\n \n \n x = x.reshape(256, 1, -1) \n x = self.layer_1(x) \n x = self.activation_1(x) \n x = self.flatten(x)\n return x\n</code></pre>\n<p>When running torchinfo<br>\nmodel = MyModel(input_size=4500, num_classes=2)<br>\ntorchinfo.summary(model, (256, 4500))</p>\n<p>I’m Getting error:</p>\n<p>Input In [101], in MyModel.forward(self, x, labels)<br>\n30 x = self.activation_1(x)<br>\n—> 31 x = self.flatten(x)<br>\n32 return x</p>\n<p>TypeError: ‘tuple’ object is not callable</p>\n<ol>\n<li>What is wrong ?</li>\n<li>What do I need to change ?</li>\n</ol>",1060 "post_number": 1,1061 "post_type": 1,1062 "posts_count": 2,1063 "updated_at": "2022-06-26T07:11:51.567Z",1064 "reply_count": 0,1065 "reply_to_post_number": null,1066 "quote_count": 0,1067 "incoming_link_count": 64,1068 "reads": 2,1069 "readers_count": 1,1070 "score": 320.4,1071 "yours": false,1072 "topic_id": 155084,1073 "topic_slug": "typeerror-tuple-object-is-not-callable-when-using-flatten-layer",1074 "display_username": "amit",1075 "primary_group_name": null,1076 "flair_name": null,1077 "flair_url": null,1078 "flair_bg_color": null,1079 "flair_color": null,1080 "flair_group_id": null,1081 "badges_granted": [],1082 "version": 1,1083 "can_edit": false,1084 "can_delete": false,1085 "can_recover": false,1086 "can_see_hidden_post": false,1087 "can_wiki": false,1088 "read": true,1089 "user_title": null,1090 "bookmarked": false,1091 "actions_summary": [],1092 "moderator": false,1093 "admin": false,1094 "staff": false,1095 "user_id": 50872,1096 "hidden": false,1097 "trust_level": 1,1098 "deleted_at": null,1099 "user_deleted": false,1100 "edit_reason": null,1101 "can_view_edit_history": true,1102 "wiki": false,1103 "post_url": "/t/typeerror-tuple-object-is-not-callable-when-using-flatten-layer/155084/1",1104 "can_accept_answer": false,1105 "can_unaccept_answer": false,1106 "accepted_answer": false,1107 "topic_accepted_answer": true,1108 "can_vote": false1109 },1110 {1111 "id": 353526,1112 "name": "",1113 "username": "ptrblck",1114 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",1115 "created_at": "2022-06-26T19:22:29.243Z",1116 "cooked": "<p>Remove the comma after <code>nn.Flatten()</code> and the error should be gone:</p>\n<pre><code class=\"lang-python\">self.flatten = nn.Flatten (), # <- note the comma\n</code></pre>",1117 "post_number": 2,1118 "post_type": 1,1119 "posts_count": 2,1120 "updated_at": "2022-06-26T19:22:29.243Z",1121 "reply_count": 0,1122 "reply_to_post_number": null,1123 "quote_count": 0,1124 "incoming_link_count": 0,1125 "reads": 2,1126 "readers_count": 1,1127 "score": 15.4,1128 "yours": false,1129 "topic_id": 155084,1130 "topic_slug": "typeerror-tuple-object-is-not-callable-when-using-flatten-layer",1131 "display_username": "",1132 "primary_group_name": null,1133 "flair_name": null,1134 "flair_url": null,1135 "flair_bg_color": null,1136 "flair_color": null,1137 "flair_group_id": null,1138 "badges_granted": [],1139 "version": 1,1140 "can_edit": false,1141 "can_delete": false,1142 "can_recover": false,1143 "can_see_hidden_post": false,1144 "can_wiki": false,1145 "read": true,1146 "user_title": "",1147 "bookmarked": false,1148 "actions_summary": [1149 {1150 "id": 2,1151 "count": 11152 }1153 ],1154 "moderator": true,1155 "admin": true,1156 "staff": true,1157 "user_id": 3534,1158 "hidden": false,1159 "trust_level": 2,1160 "deleted_at": null,1161 "user_deleted": false,1162 "edit_reason": null,1163 "can_view_edit_history": true,1164 "wiki": false,1165 "post_url": "/t/typeerror-tuple-object-is-not-callable-when-using-flatten-layer/155084/2",1166 "can_accept_answer": false,1167 "can_unaccept_answer": false,1168 "accepted_answer": true,1169 "topic_accepted_answer": true1170 }1171 ],1172 "stream": [1173 353467,1174 3535261175 ]1176 },1177 "timeline_lookup": [1178 [1179 1,1180 12181181 ],1182 [1183 2,1184 12171185 ]1186 ],1187 "suggested_topics": [1188 {1189 "fancy_title": "Embedding a float into a vector for transformer models",1190 "id": 213866,1191 "title": "Embedding a float into a vector for transformer models",1192 "slug": "embedding-a-float-into-a-vector-for-transformer-models",1193 "posts_count": 2,1194 "reply_count": 0,1195 "highest_post_number": 3,1196 "image_url": null,1197 "created_at": "2024-12-05T15:34:41.788Z",1198 "last_posted_at": "2025-01-07T11:53:28.566Z",1199 "bumped": true,1200 "bumped_at": "2025-01-07T11:59:24.716Z",