Anurag1734/cuda-error-resolution-analysis
07
1[2 {3 "post_stream": {4 "posts": [5 {6 "id": 182436,7 "name": "",8 "username": "watteo",9 "avatar_template": "/user_avatar/discuss.pytorch.org/watteo/{size}/12827_2.png",10 "created_at": "2020-04-14T20:04:44.533Z",11 "cooked": "<p>For probably unjustified reasons, I want to parameterise my <code>torch.distributions</code> objects using the natural parameters, which for a categorical are the log-probabilities.</p>\n<p>I noticed that in the <a href=\"https://pytorch.org/docs/stable/distributions.html#categorical\" rel=\"nofollow noopener\">documentation</a>, only the normalised probabilities (<code>probs</code>) and log-odds (<code>logits</code>) are supported, which seemed strange for a categorical. But on further inspection, it seems that the <code>logits</code> parameter actually refers to the log-probabilities, log p(x_i), <em>not the log-odds</em>, log p(x_i)/(1-p(x_i)). If it’s the case that <code>logits</code> actually refers to the (unnormalised) log-probabilities, maybe the documentation should be updated to avoid confusion.</p>\n<p>I know this is a pretty small error, but I did spend a non-zero amount of time trying to work out a good way to make my <code>catagorical.Categorical</code> accept log-probabilities, in a way that avoids unnecessary exponentiations. Could save someone else a few minutes too!</p>",12 "post_number": 1,13 "post_type": 1,14 "posts_count": 1,15 "updated_at": "2020-04-14T20:07:58.286Z",16 "reply_count": 0,17 "reply_to_post_number": null,18 "quote_count": 0,19 "incoming_link_count": 22,20 "reads": 6,21 "readers_count": 5,22 "score": 111.2,23 "yours": false,24 "topic_id": 76774,25 "topic_slug": "small-error-in-distributions-categorical-categorical-documentation",26 "display_username": "",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": 1,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://pytorch.org/docs/stable/distributions.html#categorical",43 "internal": false,44 "reflection": false,45 "title": "Probability distributions - torch.distributions — PyTorch master documentation",46 "clicks": 047 }48 ],49 "read": true,50 "user_title": null,51 "bookmarked": false,52 "actions_summary": [],53 "moderator": false,54 "admin": false,55 "staff": false,56 "user_id": 23453,57 "hidden": false,58 "trust_level": 1,59 "deleted_at": null,60 "user_deleted": false,61 "edit_reason": null,62 "can_view_edit_history": true,63 "wiki": false,64 "post_url": "/t/small-error-in-distributions-categorical-categorical-documentation/76774/1",65 "can_accept_answer": false,66 "can_unaccept_answer": false,67 "accepted_answer": false,68 "topic_accepted_answer": null,69 "can_vote": false70 }71 ],72 "stream": [73 18243674 ]75 },76 "timeline_lookup": [77 [78 1,79 202080 ]81 ],82 "suggested_topics": [83 {84 "fancy_title": "Changing the backbone",85 "id": 212284,86 "title": "Changing the backbone",87 "slug": "changing-the-backbone",88 "posts_count": 3,89 "reply_count": 0,90 "highest_post_number": 3,91 "image_url": null,92 "created_at": "2024-10-29T15:27:33.798Z",93 "last_posted_at": "2024-11-08T05:37:31.700Z",94 "bumped": true,95 "bumped_at": "2024-11-08T05:37:31.700Z",96 "archetype": "regular",97 "unseen": false,98 "pinned": false,99 "unpinned": null,100 "visible": true,101 "closed": false,102 "archived": false,103 "bookmarked": null,104 "liked": null,105 "tags_descriptions": {},106 "like_count": 0,107 "views": 97,108 "category_id": 1,109 "featured_link": null,110 "has_accepted_answer": false,111 "posters": [112 {113 "extras": "latest",114 "description": "Original Poster, Most Recent Poster",115 "user": {116 "id": 76804,117 "username": "afnhs-gs",118 "name": "semba",119 "avatar_template": "/letter_avatar_proxy/v4/letter/a/c5a1d2/{size}.png",120 "trust_level": 1121 }122 },123 {124 "extras": null,125 "description": "Frequent Poster",126 "user": {127 "id": 3534,128 "username": "ptrblck",129 "name": "",130 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",131 "admin": true,132 "moderator": true,133 "trust_level": 2134 }135 }136 ]137 },138 {139 "fancy_title": "Torch Execution Time Differences: 1.13.0 vs. 2.4.0",140 "id": 212711,141 "title": "Torch Execution Time Differences: 1.13.0 vs. 2.4.0",142 "slug": "torch-execution-time-differences-1-13-0-vs-2-4-0",143 "posts_count": 7,144 "reply_count": 3,145 "highest_post_number": 7,146 "image_url": null,147 "created_at": "2024-11-08T15:00:16.673Z",148 "last_posted_at": "2024-11-20T10:21:55.122Z",149 "bumped": true,150 "bumped_at": "2024-11-20T10:21:55.122Z",151 "archetype": "regular",152 "unseen": false,153 "pinned": false,154 "unpinned": null,155 "visible": true,156 "closed": false,157 "archived": false,158 "bookmarked": null,159 "liked": null,160 "tags_descriptions": {},161 "like_count": 0,162 "views": 390,163 "category_id": 1,164 "featured_link": null,165 "has_accepted_answer": false,166 "posters": [167 {168 "extras": "latest",169 "description": "Original Poster, Most Recent Poster",170 "user": {171 "id": 80773,172 "username": "nico1",173 "name": "Nico",174 "avatar_template": "/user_avatar/discuss.pytorch.org/nico1/{size}/73863_2.png",175 "trust_level": 1176 }177 },178 {179 "extras": null,180 "description": "Frequent Poster",181 "user": {182 "id": 80724,183 "username": "paulge",184 "name": "",185 "avatar_template": "/letter_avatar_proxy/v4/letter/p/82dd89/{size}.png",186 "trust_level": 2187 }188 },189 {190 "extras": null,191 "description": "Frequent Poster",192 "user": {193 "id": 3534,194 "username": "ptrblck",195 "name": "",196 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",197 "admin": true,198 "moderator": true,199 "trust_level": 2200 }201 }202 ]203 },204 {205 "fancy_title": "Regularization of weights without using error term question",206 "id": 214474,207 "title": "Regularization of weights without using error term question",208 "slug": "regularization-of-weights-without-using-error-term-question",209 "posts_count": 1,210 "reply_count": 0,211 "highest_post_number": 1,212 "image_url": null,213 "created_at": "2024-12-21T00:24:32.456Z",214 "last_posted_at": "2024-12-21T00:24:32.501Z",215 "bumped": true,216 "bumped_at": "2024-12-21T00:24:32.501Z",217 "archetype": "regular",218 "unseen": false,219 "pinned": false,220 "unpinned": null,221 "visible": true,222 "closed": false,223 "archived": false,224 "bookmarked": null,225 "liked": null,226 "tags_descriptions": {},227 "like_count": 0,228 "views": 29,229 "category_id": 1,230 "featured_link": null,231 "has_accepted_answer": false,232 "posters": [233 {234 "extras": "latest single",235 "description": "Original Poster, Most Recent Poster",236 "user": {237 "id": 57398,238 "username": "Nyakov",239 "name": "",240 "avatar_template": "/user_avatar/discuss.pytorch.org/nyakov/{size}/51180_2.png",241 "trust_level": 1242 }243 }244 ]245 },246 {247 "fancy_title": "Cuda out of memory even using different GPU with greater VRAM",248 "id": 215502,249 "title": "Cuda out of memory even using different GPU with greater VRAM",250 "slug": "cuda-out-of-memory-even-using-different-gpu-with-greater-vram",251 "posts_count": 1,252 "reply_count": 0,253 "highest_post_number": 1,254 "image_url": "https://discuss.pytorch.org/uploads/default/original/3X/7/d/7de3d05cc8e53fe8c422f1cd3f17cca381cebe9e.png",255 "created_at": "2025-01-17T03:32:21.492Z",256 "last_posted_at": "2025-01-17T03:32:21.541Z",257 "bumped": true,258 "bumped_at": "2025-01-17T03:32:21.541Z",259 "archetype": "regular",260 "unseen": false,261 "pinned": false,262 "unpinned": null,263 "visible": true,264 "closed": false,265 "archived": false,266 "bookmarked": null,267 "liked": null,268 "tags_descriptions": {},269 "like_count": 0,270 "views": 71,271 "category_id": 1,272 "featured_link": null,273 "has_accepted_answer": false,274 "posters": [275 {276 "extras": "latest single",277 "description": "Original Poster, Most Recent Poster",278 "user": {279 "id": 82136,280 "username": "EdwardJoe",281 "name": "",282 "avatar_template": "/letter_avatar_proxy/v4/letter/e/bbe5ce/{size}.png",283 "trust_level": 0284 }285 }286 ]287 },288 {289 "fancy_title": "Torch_sparse cannot find cuda lib file from pytorch",290 "id": 215733,291 "title": "Torch_sparse cannot find cuda lib file from pytorch",292 "slug": "torch-sparse-cannot-find-cuda-lib-file-from-pytorch",293 "posts_count": 6,294 "reply_count": 3,295 "highest_post_number": 6,296 "image_url": null,297 "created_at": "2025-01-22T21:56:45.806Z",298 "last_posted_at": "2025-01-23T18:24:01.921Z",299 "bumped": true,300 "bumped_at": "2025-01-23T18:24:01.921Z",301 "archetype": "regular",302 "unseen": false,303 "pinned": false,304 "unpinned": null,305 "visible": true,306 "closed": false,307 "archived": false,308 "bookmarked": null,309 "liked": null,310 "tags_descriptions": {},311 "like_count": 1,312 "views": 336,313 "category_id": 1,314 "featured_link": null,315 "has_accepted_answer": true,316 "posters": [317 {318 "extras": null,319 "description": "Original Poster",320 "user": {321 "id": 78812,322 "username": "c-earth",323 "name": "Abhijatmedhi Chotrattanapituk",324 "avatar_template": "/user_avatar/discuss.pytorch.org/c-earth/{size}/72657_2.png",325 "trust_level": 1326 }327 },328 {329 "extras": "latest",330 "description": "Most Recent Poster, Accepted Answer",331 "user": {332 "id": 3534,333 "username": "ptrblck",334 "name": "",335 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",336 "admin": true,337 "moderator": true,338 "trust_level": 2339 }340 }341 ]342 }343 ],344 "tags_descriptions": {},345 "fancy_title": "Small error in distributions.categorical.Categorical documentation",346 "id": 76774,347 "title": "Small error in distributions.categorical.Categorical documentation",348 "posts_count": 1,349 "created_at": "2020-04-14T20:04:44.482Z",350 "views": 261,351 "reply_count": 0,352 "like_count": 0,353 "last_posted_at": "2020-04-14T20:04:44.533Z",354 "visible": true,355 "closed": false,356 "archived": false,357 "has_summary": false,358 "archetype": "regular",359 "slug": "small-error-in-distributions-categorical-categorical-documentation",360 "category_id": 1,361 "word_count": 155,362 "deleted_at": null,363 "user_id": 23453,364 "featured_link": null,365 "pinned_globally": false,366 "pinned_at": null,367 "pinned_until": null,368 "image_url": null,369 "slow_mode_seconds": 0,370 "draft": null,371 "draft_key": "topic_76774",372 "draft_sequence": null,373 "unpinned": null,374 "pinned": false,375 "current_post_number": 1,376 "highest_post_number": 1,377 "deleted_by": null,378 "actions_summary": [379 {380 "id": 4,381 "count": 0,382 "hidden": false,383 "can_act": false384 },385 {386 "id": 8,387 "count": 0,388 "hidden": false,389 "can_act": false390 },391 {392 "id": 10,393 "count": 0,394 "hidden": false,395 "can_act": false396 },397 {398 "id": 7,399 "count": 0,400 "hidden": false,401 "can_act": false402 }403 ],404 "chunk_size": 20,405 "bookmarked": false,406 "topic_timer": null,407 "message_bus_last_id": 0,408 "participant_count": 1,409 "show_read_indicator": false,410 "thumbnails": null,411 "slow_mode_enabled_until": null,412 "can_vote": false,413 "vote_count": 0,414 "user_voted": false,415 "discourse_zendesk_plugin_zendesk_id": null,416 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",417 "details": {418 "can_edit": false,419 "notification_level": 1,420 "participants": [421 {422 "id": 23453,423 "username": "watteo",424 "name": "",425 "avatar_template": "/user_avatar/discuss.pytorch.org/watteo/{size}/12827_2.png",426 "post_count": 1,427 "primary_group_name": null,428 "flair_name": null,429 "flair_url": null,430 "flair_color": null,431 "flair_bg_color": null,432 "flair_group_id": null,433 "trust_level": 1434 }435 ],436 "created_by": {437 "id": 23453,438 "username": "watteo",439 "name": "",440 "avatar_template": "/user_avatar/discuss.pytorch.org/watteo/{size}/12827_2.png"441 },442 "last_poster": {443 "id": 23453,444 "username": "watteo",445 "name": "",446 "avatar_template": "/user_avatar/discuss.pytorch.org/watteo/{size}/12827_2.png"447 }448 },449 "bookmarks": []450 },451 {452 "post_stream": {453 "posts": [454 {455 "id": 181970,456 "name": "Mr. Bing",457 "username": "bing",458 "avatar_template": "/letter_avatar_proxy/v4/letter/b/839c29/{size}.png",459 "created_at": "2020-04-13T17:58:46.556Z",460 "cooked": "<p>Hi Guys,<br>\nI want to use predefined models in a system with no internet connectivity.<br>\nI know how to download it but I don’t know how to use them in a model-<br>\nI downloaded it using the below method -<br>\n<aside class=\"onebox stackexchange\">\n <header class=\"source\">\n <a href=\"https://stackoverflow.com/questions/52628270/is-there-any-way-i-can-download-the-pre-trained-models-available-in-pytorch-to-a\" target=\"_blank\" rel=\"nofollow noopener\">stackoverflow.com</a>\n </header>\n <article class=\"onebox-body\">\n <a href=\"https://stackoverflow.com/users/8085890/gopalkrizna\" target=\"_blank\" rel=\"nofollow noopener\">\n <img alt=\"gopalkrizna\" src=\"https://lh5.googleusercontent.com/-B4HnFBD_cVM/AAAAAAAAAAI/AAAAAAAAAC8/6z-DsM2EJ4o/photo.jpg?sz=128\" class=\"thumbnail onebox-avatar\" width=\"60\" height=\"60\">\n </a>\n<h4>\n <a href=\"https://stackoverflow.com/questions/52628270/is-there-any-way-i-can-download-the-pre-trained-models-available-in-pytorch-to-a\" target=\"_blank\" rel=\"nofollow noopener\">Is there any way I can download the pre-trained models available in PyTorch to a specific path?</a>\n</h4>\n\n<div class=\"tags\">\n <strong>python, deep-learning, pytorch, pre-trained-model</strong>\n</div>\n\n<div class=\"date\">\n asked by\n \n <a href=\"https://stackoverflow.com/users/8085890/gopalkrizna\" target=\"_blank\" rel=\"nofollow noopener\">\n gopalkrizna\n </a>\n on <a href=\"https://stackoverflow.com/questions/52628270/is-there-any-way-i-can-download-the-pre-trained-models-available-in-pytorch-to-a\" target=\"_blank\" rel=\"nofollow noopener\">01:35PM - 03 Oct 18 UTC</a>\n</div>\n\n </article>\n <div class=\"onebox-metadata\">\n \n \n </div>\n <div style=\"clear: both\"></div>\n</aside>\n</p>\n<p>but now I don’t know how to use them in a network-</p>",461 "post_number": 1,462 "post_type": 1,463 "posts_count": 10,464 "updated_at": "2020-04-13T17:58:46.556Z",465 "reply_count": 0,466 "reply_to_post_number": null,467 "quote_count": 0,468 "incoming_link_count": 345,469 "reads": 12,470 "readers_count": 11,471 "score": 1722.4,472 "yours": false,473 "topic_id": 76616,474 "topic_slug": "how-to-use-predefined-models-in-a-closed-system",475 "display_username": "Mr. Bing",476 "primary_group_name": null,477 "flair_name": null,478 "flair_url": null,479 "flair_bg_color": null,480 "flair_color": null,481 "flair_group_id": null,482 "badges_granted": [],483 "version": 1,484 "can_edit": false,485 "can_delete": false,486 "can_recover": false,487 "can_see_hidden_post": false,488 "can_wiki": false,489 "link_counts": [490 {491 "url": "https://stackoverflow.com/users/8085890/gopalkrizna",492 "internal": false,493 "reflection": false,494 "title": "User gopalkrizna - Stack Overflow",495 "clicks": 0496 },497 {498 "url": "https://stackoverflow.com/questions/52628270/is-there-any-way-i-can-download-the-pre-trained-models-available-in-pytorch-to-a",499 "internal": false,500 "reflection": false,501 "title": "python - Is there any way I can download the pre-trained models available in PyTorch to a specific path? - Stack Overflow",502 "clicks": 0503 }504 ],505 "read": true,506 "user_title": null,507 "bookmarked": false,508 "actions_summary": [],509 "moderator": false,510 "admin": false,511 "staff": false,512 "user_id": 25233,513 "hidden": false,514 "trust_level": 2,515 "deleted_at": null,516 "user_deleted": false,517 "edit_reason": null,518 "can_view_edit_history": true,519 "wiki": false,520 "post_url": "/t/how-to-use-predefined-models-in-a-closed-system/76616/1",521 "can_accept_answer": false,522 "can_unaccept_answer": false,523 "accepted_answer": false,524 "topic_accepted_answer": true,525 "can_vote": false526 },527 {528 "id": 181977,529 "name": "Sarvagya Vatsal Singh",530 "username": "babababadukeduke",531 "avatar_template": "/user_avatar/discuss.pytorch.org/babababadukeduke/{size}/13310_2.png",532 "created_at": "2020-04-13T18:12:05.525Z",533 "cooked": "<p>Given that you have the pre-trained model, you can always use load() to load the state dictionary from pre-trained model file into your model. The link below is very detailed and answers what you need. <a href=\"https://pytorch.org/tutorials/beginner/saving_loading_models.html\" rel=\"nofollow noopener\">https://pytorch.org/tutorials/beginner/saving_loading_models.html</a></p>",534 "post_number": 2,535 "post_type": 1,536 "posts_count": 10,537 "updated_at": "2020-04-13T18:12:05.525Z",538 "reply_count": 1,539 "reply_to_post_number": null,540 "quote_count": 0,541 "incoming_link_count": 4,542 "reads": 12,543 "readers_count": 11,544 "score": 42.4,545 "yours": false,546 "topic_id": 76616,547 "topic_slug": "how-to-use-predefined-models-in-a-closed-system",548 "display_username": "Sarvagya Vatsal Singh",549 "primary_group_name": null,550 "flair_name": null,551 "flair_url": null,552 "flair_bg_color": null,553 "flair_color": null,554 "flair_group_id": null,555 "badges_granted": [],556 "version": 1,557 "can_edit": false,558 "can_delete": false,559 "can_recover": false,560 "can_see_hidden_post": false,561 "can_wiki": false,562 "link_counts": [563 {564 "url": "https://pytorch.org/tutorials/beginner/saving_loading_models.html",565 "internal": false,566 "reflection": false,567 "title": "Saving and Loading Models — PyTorch Tutorials 1.4.0 documentation",568 "clicks": 11569 }570 ],571 "read": true,572 "user_title": null,573 "bookmarked": false,574 "actions_summary": [575 {576 "id": 2,577 "count": 1578 }579 ],580 "moderator": false,581 "admin": false,582 "staff": false,583 "user_id": 24420,584 "hidden": false,585 "trust_level": 2,586 "deleted_at": null,587 "user_deleted": false,588 "edit_reason": null,589 "can_view_edit_history": true,590 "wiki": false,591 "post_url": "/t/how-to-use-predefined-models-in-a-closed-system/76616/2",592 "can_accept_answer": false,593 "can_unaccept_answer": false,594 "accepted_answer": false,595 "topic_accepted_answer": true596 },597 {598 "id": 181982,599 "name": "Mr. Bing",600 "username": "bing",601 "avatar_template": "/letter_avatar_proxy/v4/letter/b/839c29/{size}.png",602 "created_at": "2020-04-13T18:16:20.153Z",603 "cooked": "<p>I mean I want to use, let’s say - resnet50 as a transfer learning but using the above method, they are asking me to define the model.<br>\nI used the below statement -</p>\n<pre><code class=\"lang-auto\">model_transfer = model.load_state_dict(torch.load('model.path'))\n\n</code></pre>",604 "post_number": 3,605 "post_type": 1,606 "posts_count": 10,607 "updated_at": "2020-04-13T18:16:20.153Z",608 "reply_count": 0,609 "reply_to_post_number": 2,610 "quote_count": 0,611 "incoming_link_count": 1,612 "reads": 11,613 "readers_count": 10,614 "score": 7.2,615 "yours": false,616 "topic_id": 76616,617 "topic_slug": "how-to-use-predefined-models-in-a-closed-system",618 "display_username": "Mr. Bing",619 "primary_group_name": null,620 "flair_name": null,621 "flair_url": null,622 "flair_bg_color": null,623 "flair_color": null,624 "flair_group_id": null,625 "badges_granted": [],626 "version": 1,627 "can_edit": false,628 "can_delete": false,629 "can_recover": false,630 "can_see_hidden_post": false,631 "can_wiki": false,632 "read": true,633 "user_title": null,634 "reply_to_user": {635 "id": 24420,636 "username": "babababadukeduke",637 "name": "Sarvagya Vatsal Singh",638 "avatar_template": "/user_avatar/discuss.pytorch.org/babababadukeduke/{size}/13310_2.png"639 },640 "bookmarked": false,641 "actions_summary": [],642 "moderator": false,643 "admin": false,644 "staff": false,645 "user_id": 25233,646 "hidden": false,647 "trust_level": 2,648 "deleted_at": null,649 "user_deleted": false,650 "edit_reason": null,651 "can_view_edit_history": true,652 "wiki": false,653 "post_url": "/t/how-to-use-predefined-models-in-a-closed-system/76616/3",654 "can_accept_answer": false,655 "can_unaccept_answer": false,656 "accepted_answer": false,657 "topic_accepted_answer": true658 },659 {660 "id": 182008,661 "name": "Sarvagya Vatsal Singh",662 "username": "babababadukeduke",663 "avatar_template": "/user_avatar/discuss.pytorch.org/babababadukeduke/{size}/13310_2.png",664 "created_at": "2020-04-13T19:44:41.775Z",665 "cooked": "<p>You need to define the model before you load weight in the model. This definition has to match the values in the state dictionary. If you are using standard ResNet50 for ImageNet then you can do</p>\n<p>import torchvision.models as models<br>\nmodel = models.resnet50()</p>\n<p>and then load your state dictionary into the model</p>",666 "post_number": 4,667 "post_type": 1,668 "posts_count": 10,669 "updated_at": "2020-04-13T19:44:41.775Z",670 "reply_count": 1,671 "reply_to_post_number": null,672 "quote_count": 0,673 "incoming_link_count": 1,674 "reads": 8,675 "readers_count": 7,676 "score": 41.6,677 "yours": false,678 "topic_id": 76616,679 "topic_slug": "how-to-use-predefined-models-in-a-closed-system",680 "display_username": "Sarvagya Vatsal Singh",681 "primary_group_name": null,682 "flair_name": null,683 "flair_url": null,684 "flair_bg_color": null,685 "flair_color": null,686 "flair_group_id": null,687 "badges_granted": [],688 "version": 1,689 "can_edit": false,690 "can_delete": false,691 "can_recover": false,692 "can_see_hidden_post": false,693 "can_wiki": false,694 "read": true,695 "user_title": null,696 "bookmarked": false,697 "actions_summary": [698 {699 "id": 2,700 "count": 2701 }702 ],703 "moderator": false,704 "admin": false,705 "staff": false,706 "user_id": 24420,707 "hidden": false,708 "trust_level": 2,709 "deleted_at": null,710 "user_deleted": false,711 "edit_reason": null,712 "can_view_edit_history": true,713 "wiki": false,714 "post_url": "/t/how-to-use-predefined-models-in-a-closed-system/76616/4",715 "can_accept_answer": false,716 "can_unaccept_answer": false,717 "accepted_answer": false,718 "topic_accepted_answer": true719 },720 {721 "id": 182010,722 "name": "",723 "username": "kshitij",724 "avatar_template": "/user_avatar/discuss.pytorch.org/kshitij/{size}/50811_2.png",725 "created_at": "2020-04-13T19:52:39.343Z",726 "cooked": "<p>It is like <a class=\"mention\" href=\"/u/babababadukeduke\">@babababadukeduke</a> has mentioned, you need to first define the model.</p>\n<p>Below is the example with your own defined model.</p>\n<pre><code class=\"lang-python\"># Custom Model\nclass TwoLayerNet(torch.nn.Module):\n def __init__(self, D_in, H, D_out):\n \"\"\"\n In the constructor we instantiate two nn.Linear modules and assign them as\n member variables.\n \"\"\"\n super(TwoLayerNet, self).__init__()\n self.linear1 = torch.nn.Linear(D_in, H)\n self.linear2 = torch.nn.Linear(H, D_out)\n\n def forward(self, x):\n \"\"\"\n In the forward function we accept a Tensor of input data and we must return\n a Tensor of output data. We can use Modules defined in the constructor as\n well as arbitrary operators on Tensors.\n \"\"\"\n h_relu = self.linear1(x).clamp(min=0)\n y_pred = self.linear2(h_relu)\n return y_pred\n\n# Model Object / Blueprint\nmodel = TwoLayerNet(D_in, H, D_out)\n\n\n# Load the weights into the model.\nmodel_transfer = model.load_state_dict(torch.load('model.path')) # Weight from same blue print.\n</code></pre>",727 "post_number": 5,728 "post_type": 1,729 "posts_count": 10,730 "updated_at": "2020-04-13T19:52:39.343Z",731 "reply_count": 0,732 "reply_to_post_number": null,733 "quote_count": 0,734 "incoming_link_count": 7,735 "reads": 8,736 "readers_count": 7,737 "score": 66.6,738 "yours": false,739 "topic_id": 76616,740 "topic_slug": "how-to-use-predefined-models-in-a-closed-system",741 "display_username": "",742 "primary_group_name": null,743 "flair_name": null,744 "flair_url": null,745 "flair_bg_color": null,746 "flair_color": null,747 "flair_group_id": null,748 "badges_granted": [],749 "version": 1,750 "can_edit": false,751 "can_delete": false,752 "can_recover": false,753 "can_see_hidden_post": false,754 "can_wiki": false,755 "read": true,756 "user_title": null,757 "bookmarked": false,758 "actions_summary": [759 {760 "id": 2,761 "count": 2762 }763 ],764 "moderator": false,765 "admin": false,766 "staff": false,767 "user_id": 12112,768 "hidden": false,769 "trust_level": 2,770 "deleted_at": null,771 "user_deleted": false,772 "edit_reason": null,773 "can_view_edit_history": true,774 "wiki": false,775 "post_url": "/t/how-to-use-predefined-models-in-a-closed-system/76616/5",776 "can_accept_answer": false,777 "can_unaccept_answer": false,778 "accepted_answer": false,779 "topic_accepted_answer": true780 },781 {782 "id": 182384,783 "name": "Mr. Bing",784 "username": "bing",785 "avatar_template": "/letter_avatar_proxy/v4/letter/b/839c29/{size}.png",786 "created_at": "2020-04-14T17:43:38.327Z",787 "cooked": "<p>I just did that but I don’t think it is behaving exactly I intend it to behave-</p>\n<pre><code class=\"lang-auto\">model_transfer = models.resnet50()\nmodel_transfer = model_transfer.load_state_dict(torch.load(model_path))\n</code></pre>\n<p>Now, if I print <code>model_transfer</code> then isn’t the complete architecture should come up but I am getting -<br>\n<code><All keys matched successfully></code> and no architecture.<br>\nAlso, if then just want to modify last layers using <code>model_transfer.fc.in_features</code> then it should work but instead I am getting<br>\n<code>AttributeError: '_IncompatibleKeys' object has no attribute 'fc'</code></p>",788 "post_number": 6,789 "post_type": 1,790 "posts_count": 10,791 "updated_at": "2020-04-14T17:43:38.327Z",792 "reply_count": 0,793 "reply_to_post_number": 4,794 "quote_count": 0,795 "incoming_link_count": 4,796 "reads": 7,797 "readers_count": 6,798 "score": 21.4,799 "yours": false,800 "topic_id": 76616,801 "topic_slug": "how-to-use-predefined-models-in-a-closed-system",802 "display_username": "Mr. Bing",803 "primary_group_name": null,804 "flair_name": null,805 "flair_url": null,806 "flair_bg_color": null,807 "flair_color": null,808 "flair_group_id": null,809 "badges_granted": [],810 "version": 1,811 "can_edit": false,812 "can_delete": false,813 "can_recover": false,814 "can_see_hidden_post": false,815 "can_wiki": false,816 "read": true,817 "user_title": null,818 "reply_to_user": {819 "id": 24420,820 "username": "babababadukeduke",821 "name": "Sarvagya Vatsal Singh",822 "avatar_template": "/user_avatar/discuss.pytorch.org/babababadukeduke/{size}/13310_2.png"823 },824 "bookmarked": false,825 "actions_summary": [],826 "moderator": false,827 "admin": false,828 "staff": false,829 "user_id": 25233,830 "hidden": false,831 "trust_level": 2,832 "deleted_at": null,833 "user_deleted": false,834 "edit_reason": null,835 "can_view_edit_history": true,836 "wiki": false,837 "post_url": "/t/how-to-use-predefined-models-in-a-closed-system/76616/6",838 "can_accept_answer": false,839 "can_unaccept_answer": false,840 "accepted_answer": false,841 "topic_accepted_answer": true842 },843 {844 "id": 182400,845 "name": "Sarvagya Vatsal Singh",846 "username": "babababadukeduke",847 "avatar_template": "/user_avatar/discuss.pytorch.org/babababadukeduke/{size}/13310_2.png",848 "created_at": "2020-04-14T18:38:08.016Z",849 "cooked": "<p><code> <All keys matched successfully></code> means that you were able to successfully load the model parameters in the file. You can do <code>print(model_transfer)</code> and see the architecture. If you can post the code of how you are trying to modify the model then maybe I will be able to point out the exact problem.</p>",850 "post_number": 7,851 "post_type": 1,852 "posts_count": 10,853 "updated_at": "2020-04-14T18:38:08.016Z",854 "reply_count": 1,855 "reply_to_post_number": null,856 "quote_count": 0,857 "incoming_link_count": 4,858 "reads": 7,859 "readers_count": 6,860 "score": 41.4,861 "yours": false,862 "topic_id": 76616,863 "topic_slug": "how-to-use-predefined-models-in-a-closed-system",864 "display_username": "Sarvagya Vatsal Singh",865 "primary_group_name": null,866 "flair_name": null,867 "flair_url": null,868 "flair_bg_color": null,869 "flair_color": null,870 "flair_group_id": null,871 "badges_granted": [],872 "version": 1,873 "can_edit": false,874 "can_delete": false,875 "can_recover": false,876 "can_see_hidden_post": false,877 "can_wiki": false,878 "read": true,879 "user_title": null,880 "bookmarked": false,881 "actions_summary": [882 {883 "id": 2,884 "count": 1885 }886 ],887 "moderator": false,888 "admin": false,889 "staff": false,890 "user_id": 24420,891 "hidden": false,892 "trust_level": 2,893 "deleted_at": null,894 "user_deleted": false,895 "edit_reason": null,896 "can_view_edit_history": true,897 "wiki": false,898 "post_url": "/t/how-to-use-predefined-models-in-a-closed-system/76616/7",899 "can_accept_answer": false,900 "can_unaccept_answer": false,901 "accepted_answer": false,902 "topic_accepted_answer": true903 },904 {905 "id": 182413,906 "name": "Mr. Bing",907 "username": "bing",908 "avatar_template": "/letter_avatar_proxy/v4/letter/b/839c29/{size}.png",909 "created_at": "2020-04-14T19:15:03.967Z",910 "cooked": "<p>I went <a href=\"https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py\" rel=\"nofollow noopener\">here</a> , then downloaded the required model file and saved in my computer.<br>\nThen, I did -</p>\n<pre><code class=\"lang-auto\">import torchvision.models as models\nimport torch.nn as nn\nmodel_path = 'Path_to_model/resnet_50.pth'\nmodel_transfer = models.resnet50()\nmodel_transfer = model_transfer.load_state_dict(torch.load(model_path))\nprint(model_transfer)\n</code></pre>\n<p>and I am getting <code><All keys matched successfully></code><br>\non doing this.</p>",911 "post_number": 8,912 "post_type": 1,913 "posts_count": 10,914 "updated_at": "2020-04-14T19:15:03.967Z",915 "reply_count": 0,916 "reply_to_post_number": 7,917 "quote_count": 0,918 "incoming_link_count": 10,919 "reads": 7,920 "readers_count": 6,921 "score": 51.4,922 "yours": false,923 "topic_id": 76616,924 "topic_slug": "how-to-use-predefined-models-in-a-closed-system",925 "display_username": "Mr. Bing",926 "primary_group_name": null,927 "flair_name": null,928 "flair_url": null,929 "flair_bg_color": null,930 "flair_color": null,931 "flair_group_id": null,932 "badges_granted": [],933 "version": 1,934 "can_edit": false,935 "can_delete": false,936 "can_recover": false,937 "can_see_hidden_post": false,938 "can_wiki": false,939 "link_counts": [940 {941 "url": "https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py",942 "internal": false,943 "reflection": false,944 "title": "vision/resnet.py at master · pytorch/vision · GitHub",945 "clicks": 3946 }947 ],948 "read": true,949 "user_title": null,950 "reply_to_user": {951 "id": 24420,952 "username": "babababadukeduke",953 "name": "Sarvagya Vatsal Singh",954 "avatar_template": "/user_avatar/discuss.pytorch.org/babababadukeduke/{size}/13310_2.png"955 },956 "bookmarked": false,957 "actions_summary": [],958 "moderator": false,959 "admin": false,960 "staff": false,961 "user_id": 25233,962 "hidden": false,963 "trust_level": 2,964 "deleted_at": null,965 "user_deleted": false,966 "edit_reason": null,967 "can_view_edit_history": true,968 "wiki": false,969 "post_url": "/t/how-to-use-predefined-models-in-a-closed-system/76616/8",970 "can_accept_answer": false,971 "can_unaccept_answer": false,972 "accepted_answer": false,973 "topic_accepted_answer": true974 },975 {976 "id": 182414,977 "name": "",978 "username": "kshitij",979 "avatar_template": "/user_avatar/discuss.pytorch.org/kshitij/{size}/50811_2.png",980 "created_at": "2020-04-14T19:21:05.133Z",981 "cooked": "<pre><code class=\"lang-python\">import torchvision.models as models\nimport torch.nn as nn\nmodel_path = 'Path_to_model/resnet_50.pth'\nmodel_transfer = models.resnet50()\nmissing_keys, unexpected_keys = model_transfer.load_state_dict(torch.load(model_path))\nprint(model_transfer)\n</code></pre>\n<p><a href=\"https://pytorch.org/docs/stable/nn.html?highlight=load_state_dict#torch.nn.Module.load_state_dict\" class=\"onebox\" target=\"_blank\" rel=\"nofollow noopener\">https://pytorch.org/docs/stable/nn.html?highlight=load_state_dict#torch.nn.Module.load_state_dict</a></p>\n<p>Looking at the documentation, <code>load_state_dict</code> returns <code>missing_keys,unexpected_keys</code> and loads the model in the <code>model_transfer</code> object itself.</p>",982 "post_number": 9,983 "post_type": 1,984 "posts_count": 10,985 "updated_at": "2020-04-14T19:22:42.377Z",986 "reply_count": 1,987 "reply_to_post_number": null,988 "quote_count": 0,989 "incoming_link_count": 6,990 "reads": 7,991 "readers_count": 6,992 "score": 51.4,993 "yours": false,994 "topic_id": 76616,995 "topic_slug": "how-to-use-predefined-models-in-a-closed-system",996 "display_username": "",997 "primary_group_name": null,998 "flair_name": null,999 "flair_url": null,1000 "flair_bg_color": null,1001 "flair_color": null,1002 "flair_group_id": null,1003 "badges_granted": [],1004 "version": 1,1005 "can_edit": false,1006 "can_delete": false,1007 "can_recover": false,1008 "can_see_hidden_post": false,1009 "can_wiki": false,1010 "link_counts": [1011 {1012 "url": "https://pytorch.org/docs/stable/nn.html?highlight=load_state_dict#torch.nn.Module.load_state_dict",1013 "internal": false,1014 "reflection": false,1015 "title": "torch.nn — PyTorch master documentation",1016 "clicks": 91017 }1018 ],1019 "read": true,1020 "user_title": null,1021 "bookmarked": false,1022 "actions_summary": [1023 {1024 "id": 2,1025 "count": 11026 }1027 ],1028 "moderator": false,1029 "admin": false,1030 "staff": false,1031 "user_id": 12112,1032 "hidden": false,1033 "trust_level": 2,1034 "deleted_at": null,1035 "user_deleted": false,1036 "edit_reason": null,1037 "can_view_edit_history": true,1038 "wiki": false,1039 "post_url": "/t/how-to-use-predefined-models-in-a-closed-system/76616/9",1040 "can_accept_answer": false,1041 "can_unaccept_answer": false,1042 "accepted_answer": true,1043 "topic_accepted_answer": true1044 },1045 {1046 "id": 182415,1047 "name": "Mr. Bing",1048 "username": "bing",1049 "avatar_template": "/letter_avatar_proxy/v4/letter/b/839c29/{size}.png",1050 "created_at": "2020-04-14T19:22:50.610Z",1051 "cooked": "<p>Thank You, it worked.</p>",1052 "post_number": 10,1053 "post_type": 1,1054 "posts_count": 10,1055 "updated_at": "2020-04-14T19:22:50.610Z",1056 "reply_count": 0,1057 "reply_to_post_number": 9,1058 "quote_count": 0,1059 "incoming_link_count": 2,1060 "reads": 6,1061 "readers_count": 5,1062 "score": 26.2,1063 "yours": false,1064 "topic_id": 76616,1065 "topic_slug": "how-to-use-predefined-models-in-a-closed-system",1066 "display_username": "Mr. Bing",1067 "primary_group_name": null,1068 "flair_name": null,1069 "flair_url": null,1070 "flair_bg_color": null,1071 "flair_color": null,1072 "flair_group_id": null,1073 "badges_granted": [],1074 "version": 1,1075 "can_edit": false,1076 "can_delete": false,1077 "can_recover": false,1078 "can_see_hidden_post": false,1079 "can_wiki": false,1080 "read": true,1081 "user_title": null,1082 "reply_to_user": {1083 "id": 12112,1084 "username": "kshitij",1085 "name": "",1086 "avatar_template": "/user_avatar/discuss.pytorch.org/kshitij/{size}/50811_2.png"1087 },1088 "bookmarked": false,1089 "actions_summary": [1090 {1091 "id": 2,1092 "count": 11093 }1094 ],1095 "moderator": false,1096 "admin": false,1097 "staff": false,1098 "user_id": 25233,1099 "hidden": false,1100 "trust_level": 2,1101 "deleted_at": null,1102 "user_deleted": false,1103 "edit_reason": null,1104 "can_view_edit_history": true,1105 "wiki": false,1106 "post_url": "/t/how-to-use-predefined-models-in-a-closed-system/76616/10",1107 "can_accept_answer": false,1108 "can_unaccept_answer": false,1109 "accepted_answer": false,1110 "topic_accepted_answer": true1111 }1112 ],1113 "stream": [1114 181970,1115 181977,1116 181982,1117 182008,1118 182010,1119 182384,1120 182400,1121 182413,1122 182414,1123 1824151124 ]1125 },1126 "timeline_lookup": [1127 [1128 1,1129 20211130 ],1131 [1132 6,1133 20201134 ]1135 ],1136 "suggested_topics": [1137 {1138 "fancy_title": "How to liberate CUDA Memory succesfully?",1139 "id": 214081,1140 "title": "How to liberate CUDA Memory succesfully?",1141 "slug": "how-to-liberate-cuda-memory-succesfully",1142 "posts_count": 2,1143 "reply_count": 0,1144 "highest_post_number": 2,1145 "image_url": "https://discuss.pytorch.org/uploads/default/original/3X/a/f/af1fa59e98fb53eb6f25e7f62b3371828b56f185.png",1146 "created_at": "2024-12-11T01:04:45.736Z",1147 "last_posted_at": "2024-12-11T14:08:23.450Z",1148 "bumped": true,1149 "bumped_at": "2024-12-11T14:08:23.450Z",1150 "archetype": "regular",1151 "unseen": false,1152 "pinned": false,1153 "unpinned": null,1154 "visible": true,1155 "closed": false,1156 "archived": false,1157 "bookmarked": null,1158 "liked": null,1159 "tags_descriptions": {},1160 "like_count": 0,1161 "views": 230,1162 "category_id": 1,1163 "featured_link": null,1164 "has_accepted_answer": false,1165 "posters": [1166 {1167 "extras": null,1168 "description": "Original Poster",1169 "user": {1170 "id": 81441,1171 "username": "Jose_Leyva",1172 "name": "Jose Leyva",1173 "avatar_template": "/user_avatar/discuss.pytorch.org/jose_leyva/{size}/74460_2.png",1174 "trust_level": 11175 }1176 },1177 {1178 "extras": "latest",1179 "description": "Most Recent Poster",1180 "user": {1181 "id": 3534,1182 "username": "ptrblck",1183 "name": "",1184 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",1185 "admin": true,1186 "moderator": true,1187 "trust_level": 21188 }1189 }1190 ]1191 },1192 {1193 "fancy_title": "How to run PyTorch DDP with Hydra + Optuna?",1194 "id": 213316,1195 "title": "How to run PyTorch DDP with Hydra + Optuna?",1196 "slug": "how-to-run-pytorch-ddp-with-hydra-optuna",1197 "posts_count": 1,1198 "reply_count": 0,1199 "highest_post_number": 1,1200 "image_url": null,