Anurag1734/cuda-error-resolution-analysis
07
1[2 {3 "post_stream": {4 "posts": [5 {6 "id": 18744,7 "name": "balaji",8 "username": "balaji",9 "avatar_template": "/letter_avatar_proxy/v4/letter/b/2bfe46/{size}.png",10 "created_at": "2017-09-24T07:25:57.649Z",11 "cooked": "<p>Hi all,<br>\nI was able to implement Resnet34 using the class as follows</p>\n<pre><code class=\"lang-python\">class Resnet34(nn.Module):\n def __init__(self, num_classes = 10):\n super(Resnet34,self).__init__()\n original_model = models.resnet34(pretrained=True)\n self.features = nn.Sequential(*list(original_model.children())[:-1])\n self.classifier = nn.Sequential(nn.Linear(512, num_classes))\n\n def forward(self, x):\n f = self.features(x)\n f = f.view(f.size(0), -1)\n\t\ty = self.classifier(f)\n return f,y\n</code></pre>\n<p>But when i try similar approach for densenet.</p>\n<pre><code class=\"lang-python\">class Densenet161(nn.Module):\n def __init__(self, num_classes = 2):\n super(Densenet161,self).__init__()\n original_model = models.densenet161(pretrained=True)\n self.features = nn.Sequential(*list(original_model.children())[:-1])\n self.classifier = (nn.Linear(2208, num_classes))\n\n def forward(self, x):\n f = self.features(x)\n f = f.view(f.size(0), -1)\n\t\ty = self.classifier(f)\n return f,y\n</code></pre>\n<p>I get the following error</p>\n<pre><code class=\"lang-auto\">RuntimeError: size mismatch at /py/conda-bld/pytorch_1493676237139/work/torch/lib/THC/generic/THCTensorMathBlas.cu:243\n</code></pre>\n<p>I am using the same code used in Pytorch transfer learning fine tuning example.<br>\nPlease suggest a method to sort the issue</p>",12 "post_number": 1,13 "post_type": 1,14 "posts_count": 5,15 "updated_at": "2017-09-28T14:59:41.283Z",16 "reply_count": 0,17 "reply_to_post_number": null,18 "quote_count": 0,19 "incoming_link_count": 2261,20 "reads": 120,21 "readers_count": 119,22 "score": 11329.0,23 "yours": false,24 "topic_id": 7776,25 "topic_slug": "densenet-transfer-learning",26 "display_username": "balaji",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 "read": true,41 "user_title": null,42 "bookmarked": false,43 "actions_summary": [],44 "moderator": false,45 "admin": false,46 "staff": false,47 "user_id": 3538,48 "hidden": false,49 "trust_level": 1,50 "deleted_at": null,51 "user_deleted": false,52 "edit_reason": null,53 "can_view_edit_history": true,54 "wiki": false,55 "post_url": "/t/densenet-transfer-learning/7776/1",56 "can_accept_answer": false,57 "can_unaccept_answer": false,58 "accepted_answer": false,59 "topic_accepted_answer": null,60 "can_vote": false61 },62 {63 "id": 19280,64 "name": "",65 "username": "smth",66 "avatar_template": "/user_avatar/discuss.pytorch.org/smth/{size}/13_2.png",67 "created_at": "2017-09-28T15:05:10.805Z",68 "cooked": "<p>It is best to read the model definitions first, otherwise you wont know what’s wrong.<br>\nDensenet has average pooling before the classifier stage:<br>\n<aside class=\"onebox githubblob\">\n <header class=\"source\">\n <a href=\"https://github.com/pytorch/vision/blob/master/torchvision/models/densenet.py#L158-L159\" target=\"_blank\" rel=\"nofollow noopener\">github.com</a>\n </header>\n <article class=\"onebox-body\">\n <h4><a href=\"https://github.com/pytorch/vision/blob/master/torchvision/models/densenet.py#L158-L159\" target=\"_blank\" rel=\"nofollow noopener\">pytorch/vision/blob/master/torchvision/models/densenet.py#L158-L159</a></h4>\n<pre class=\"onebox\"><code class=\"lang-py\"><ol class=\"start lines\" start=\"158\" style=\"counter-reset: li-counter 157 ;\">\n<li>if isinstance(m, nn.Conv2d):</li>\n<li> nn.init.kaiming_normal(m.weight.data)</li>\n</ol></code></pre>\n\n\n </article>\n <div class=\"onebox-metadata\">\n \n \n </div>\n <div style=\"clear: both\"></div>\n</aside>\n</p>\n<p>Here’s a corrected version:</p>\n<pre><code class=\"lang-auto\">import torch\nimport torch.nn as nn\nfrom torch.autograd import Variable\nimport torchvision.models as models\nimport torch.nn.functional as F\n\nclass Densenet161(nn.Module):\n def __init__(self, num_classes = 2):\n super(Densenet161,self).__init__()\n original_model = models.densenet161()\n self.features = nn.Sequential(*list(original_model.children())[:-1])\n self.classifier = (nn.Linear(2208, num_classes))\n\n def forward(self, x):\n f = self.features(x)\n f = F.relu(f, inplace=True)\n f = F.avg_pool2d(f, kernel_size=7).view(f.size(0), -1)\n y = self.classifier(f)\n return f,y\n\n\nx = Densenet161()\n\ninp = Variable(torch.randn(4, 3, 224, 224))\n\nout = x(inp)\n</code></pre>",69 "post_number": 2,70 "post_type": 1,71 "posts_count": 5,72 "updated_at": "2017-09-28T15:05:10.805Z",73 "reply_count": 1,74 "reply_to_post_number": null,75 "quote_count": 0,76 "incoming_link_count": 92,77 "reads": 103,78 "readers_count": 102,79 "score": 532.6,80 "yours": false,81 "topic_id": 7776,82 "topic_slug": "densenet-transfer-learning",83 "display_username": "",84 "primary_group_name": null,85 "flair_name": null,86 "flair_url": null,87 "flair_bg_color": null,88 "flair_color": null,89 "flair_group_id": null,90 "badges_granted": [],91 "version": 1,92 "can_edit": false,93 "can_delete": false,94 "can_recover": false,95 "can_see_hidden_post": false,96 "can_wiki": false,97 "link_counts": [98 {99 "url": "https://github.com/pytorch/vision/blob/master/torchvision/models/densenet.py#L158-L159",100 "internal": false,101 "reflection": false,102 "title": "vision/densenet.py at master · pytorch/vision · GitHub",103 "clicks": 102104 }105 ],106 "read": true,107 "user_title": "PyTorch Dev, Facebook AI Research",108 "title_is_group": false,109 "bookmarked": false,110 "actions_summary": [111 {112 "id": 2,113 "count": 2114 }115 ],116 "moderator": true,117 "admin": true,118 "staff": true,119 "user_id": 1,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/densenet-transfer-learning/7776/2",128 "can_accept_answer": false,129 "can_unaccept_answer": false,130 "accepted_answer": false,131 "topic_accepted_answer": null132 },133 {134 "id": 19482,135 "name": "balaji",136 "username": "balaji",137 "avatar_template": "/letter_avatar_proxy/v4/letter/b/2bfe46/{size}.png",138 "created_at": "2017-09-29T12:31:57.127Z",139 "cooked": "<p>Thanks <a class=\"mention\" href=\"/u/smth\">@smth</a> … I downloaded the densenet code from the pytorch git and I modified the model as per my need. Its working good. Thanks</p>",140 "post_number": 3,141 "post_type": 1,142 "posts_count": 5,143 "updated_at": "2017-09-29T12:31:57.127Z",144 "reply_count": 0,145 "reply_to_post_number": 2,146 "quote_count": 0,147 "incoming_link_count": 8,148 "reads": 85,149 "readers_count": 84,150 "score": 57.0,151 "yours": false,152 "topic_id": 7776,153 "topic_slug": "densenet-transfer-learning",154 "display_username": "balaji",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": 1,172 "username": "smth",173 "name": "",174 "avatar_template": "/user_avatar/discuss.pytorch.org/smth/{size}/13_2.png"175 },176 "bookmarked": false,177 "actions_summary": [],178 "moderator": false,179 "admin": false,180 "staff": false,181 "user_id": 3538,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/densenet-transfer-learning/7776/3",190 "can_accept_answer": false,191 "can_unaccept_answer": false,192 "accepted_answer": false,193 "topic_accepted_answer": null194 },195 {196 "id": 42205,197 "name": "Muralidhar",198 "username": "muralidharpettela",199 "avatar_template": "/letter_avatar_proxy/v4/letter/m/71e660/{size}.png",200 "created_at": "2018-04-16T08:48:39.739Z",201 "cooked": "<p>Here is the correct code for Transfer learning with densenet<br>\ndset_classes_number = len(class_names)<br>\nmodel_ft = models.densenet121(pretrained=True)<br>\nmodel_ft.classifier = nn.Linear(1024, dset_classes_number)</p>",202 "post_number": 4,203 "post_type": 1,204 "posts_count": 5,205 "updated_at": "2018-04-16T08:48:39.739Z",206 "reply_count": 1,207 "reply_to_post_number": null,208 "quote_count": 0,209 "incoming_link_count": 17,210 "reads": 55,211 "readers_count": 54,212 "score": 131.0,213 "yours": false,214 "topic_id": 7776,215 "topic_slug": "densenet-transfer-learning",216 "display_username": "Muralidhar",217 "primary_group_name": null,218 "flair_name": null,219 "flair_url": null,220 "flair_bg_color": null,221 "flair_color": null,222 "flair_group_id": null,223 "badges_granted": [],224 "version": 1,225 "can_edit": false,226 "can_delete": false,227 "can_recover": false,228 "can_see_hidden_post": false,229 "can_wiki": false,230 "read": true,231 "user_title": null,232 "bookmarked": false,233 "actions_summary": [234 {235 "id": 2,236 "count": 2237 }238 ],239 "moderator": false,240 "admin": false,241 "staff": false,242 "user_id": 7669,243 "hidden": false,244 "trust_level": 1,245 "deleted_at": null,246 "user_deleted": false,247 "edit_reason": null,248 "can_view_edit_history": true,249 "wiki": false,250 "post_url": "/t/densenet-transfer-learning/7776/4",251 "can_accept_answer": false,252 "can_unaccept_answer": false,253 "accepted_answer": false,254 "topic_accepted_answer": null255 },256 {257 "id": 122041,258 "name": "锦海 杨",259 "username": "111104",260 "avatar_template": "/user_avatar/discuss.pytorch.org/111104/{size}/13905_2.png",261 "created_at": "2019-07-09T10:52:34.123Z",262 "cooked": "<p>Thanks! Work perfectly!</p>",263 "post_number": 5,264 "post_type": 1,265 "posts_count": 5,266 "updated_at": "2019-07-09T10:52:34.123Z",267 "reply_count": 0,268 "reply_to_post_number": 4,269 "quote_count": 0,270 "incoming_link_count": 3,271 "reads": 21,272 "readers_count": 20,273 "score": 19.2,274 "yours": false,275 "topic_id": 7776,276 "topic_slug": "densenet-transfer-learning",277 "display_username": "锦海 杨",278 "primary_group_name": null,279 "flair_name": null,280 "flair_url": null,281 "flair_bg_color": null,282 "flair_color": null,283 "flair_group_id": null,284 "badges_granted": [],285 "version": 1,286 "can_edit": false,287 "can_delete": false,288 "can_recover": false,289 "can_see_hidden_post": false,290 "can_wiki": false,291 "read": true,292 "user_title": null,293 "reply_to_user": {294 "id": 7669,295 "username": "muralidharpettela",296 "name": "Muralidhar",297 "avatar_template": "/letter_avatar_proxy/v4/letter/m/71e660/{size}.png"298 },299 "bookmarked": false,300 "actions_summary": [],301 "moderator": false,302 "admin": false,303 "staff": false,304 "user_id": 20420,305 "hidden": false,306 "trust_level": 1,307 "deleted_at": null,308 "user_deleted": false,309 "edit_reason": null,310 "can_view_edit_history": true,311 "wiki": false,312 "post_url": "/t/densenet-transfer-learning/7776/5",313 "can_accept_answer": false,314 "can_unaccept_answer": false,315 "accepted_answer": false,316 "topic_accepted_answer": null317 }318 ],319 "stream": [320 18744,321 19280,322 19482,323 42205,324 122041325 ]326 },327 "timeline_lookup": [328 [329 1,330 2954331 ],332 [333 2,334 2949335 ],336 [337 4,338 2750339 ],340 [341 5,342 2301343 ]344 ],345 "suggested_topics": [346 {347 "fancy_title": "Using Tensor subclasses for chunked loss and backprop?",348 "id": 212525,349 "title": "Using Tensor subclasses for chunked loss and backprop?",350 "slug": "using-tensor-subclasses-for-chunked-loss-and-backprop",351 "posts_count": 2,352 "reply_count": 0,353 "highest_post_number": 2,354 "image_url": null,355 "created_at": "2024-11-04T22:53:06.246Z",356 "last_posted_at": "2024-12-06T15:41:33.679Z",357 "bumped": true,358 "bumped_at": "2024-12-06T15:41:33.679Z",359 "archetype": "regular",360 "unseen": false,361 "pinned": false,362 "unpinned": null,363 "visible": true,364 "closed": false,365 "archived": false,366 "bookmarked": null,367 "liked": null,368 "tags_descriptions": {},369 "like_count": 0,370 "views": 198,371 "category_id": 1,372 "featured_link": null,373 "has_accepted_answer": false,374 "posters": [375 {376 "extras": null,377 "description": "Original Poster",378 "user": {379 "id": 8274,380 "username": "cbcase",381 "name": "Carl C",382 "avatar_template": "/user_avatar/discuss.pytorch.org/cbcase/{size}/61078_2.png",383 "trust_level": 1384 }385 },386 {387 "extras": "latest",388 "description": "Most Recent Poster",389 "user": {390 "id": 211,391 "username": "albanD",392 "name": "Alban D",393 "avatar_template": "/user_avatar/discuss.pytorch.org/alband/{size}/215_2.png",394 "admin": true,395 "moderator": true,396 "trust_level": 4397 }398 }399 ]400 },401 {402 "fancy_title": "What’s the theoreticl basis of torch.testing tolerance table?",403 "id": 213255,404 "title": "What's the theoreticl basis of torch.testing tolerance table?",405 "slug": "whats-the-theoreticl-basis-of-torch-testing-tolerance-table",406 "posts_count": 1,407 "reply_count": 0,408 "highest_post_number": 1,409 "image_url": "https://discuss.pytorch.org/uploads/default/optimized/3X/7/0/704c9ddf26dc72ffe8f69312a123846fdab78ded_2_1024x736.png",410 "created_at": "2024-11-21T07:42:12.294Z",411 "last_posted_at": "2024-11-21T07:42:12.347Z",412 "bumped": true,413 "bumped_at": "2024-11-21T07:42:12.347Z",414 "archetype": "regular",415 "unseen": false,416 "pinned": false,417 "unpinned": null,418 "visible": true,419 "closed": false,420 "archived": false,421 "bookmarked": null,422 "liked": null,423 "tags_descriptions": {},424 "like_count": 0,425 "views": 25,426 "category_id": 1,427 "featured_link": null,428 "has_accepted_answer": false,429 "posters": [430 {431 "extras": "latest single",432 "description": "Original Poster, Most Recent Poster",433 "user": {434 "id": 81043,435 "username": "Jiexin-Zheng",436 "name": "Jiexin Zheng",437 "avatar_template": "/user_avatar/discuss.pytorch.org/jiexin-zheng/{size}/74108_2.png",438 "trust_level": 0439 }440 }441 ]442 },443 {444 "fancy_title": "Broadcasting vs repeating",445 "id": 214419,446 "title": "Broadcasting vs repeating",447 "slug": "broadcasting-vs-repeating",448 "posts_count": 2,449 "reply_count": 0,450 "highest_post_number": 2,451 "image_url": null,452 "created_at": "2024-12-19T20:41:05.163Z",453 "last_posted_at": "2024-12-19T21:49:15.855Z",454 "bumped": true,455 "bumped_at": "2024-12-19T21:49:15.855Z",456 "archetype": "regular",457 "unseen": false,458 "pinned": false,459 "unpinned": null,460 "visible": true,461 "closed": false,462 "archived": false,463 "bookmarked": null,464 "liked": null,465 "tags_descriptions": {},466 "like_count": 1,467 "views": 165,468 "category_id": 1,469 "featured_link": null,470 "has_accepted_answer": false,471 "posters": [472 {473 "extras": null,474 "description": "Original Poster",475 "user": {476 "id": 72757,477 "username": "sherlock.h",478 "name": "",479 "avatar_template": "/user_avatar/discuss.pytorch.org/sherlock.h/{size}/62377_2.png",480 "trust_level": 1481 }482 },483 {484 "extras": "latest",485 "description": "Most Recent Poster",486 "user": {487 "id": 41396,488 "username": "soulitzer",489 "name": "",490 "avatar_template": "/letter_avatar_proxy/v4/letter/s/839c29/{size}.png",491 "trust_level": 2492 }493 }494 ]495 },496 {497 "fancy_title": "How to categorize tensor float values into long values?",498 "id": 214711,499 "title": "How to categorize tensor float values into long values?",500 "slug": "how-to-categorize-tensor-float-values-into-long-values",501 "posts_count": 2,502 "reply_count": 0,503 "highest_post_number": 2,504 "image_url": null,505 "created_at": "2024-12-27T20:32:46.532Z",506 "last_posted_at": "2024-12-27T23:52:07.865Z",507 "bumped": true,508 "bumped_at": "2024-12-27T23:52:07.865Z",509 "archetype": "regular",510 "unseen": false,511 "pinned": false,512 "unpinned": null,513 "visible": true,514 "closed": false,515 "archived": false,516 "bookmarked": null,517 "liked": null,518 "tags_descriptions": {},519 "like_count": 0,520 "views": 33,521 "category_id": 1,522 "featured_link": null,523 "has_accepted_answer": true,524 "posters": [525 {526 "extras": null,527 "description": "Original Poster",528 "user": {529 "id": 78321,530 "username": "Omaralmaqtari",531 "name": "Omar al-maqtari",532 "avatar_template": "/user_avatar/discuss.pytorch.org/omaralmaqtari/{size}/72219_2.png",533 "trust_level": 1534 }535 },536 {537 "extras": "latest",538 "description": "Most Recent Poster, Accepted Answer",539 "user": {540 "id": 41396,541 "username": "soulitzer",542 "name": "",543 "avatar_template": "/letter_avatar_proxy/v4/letter/s/839c29/{size}.png",544 "trust_level": 2545 }546 }547 ]548 },549 {550 "fancy_title": "Cannot overfit MLP on random batch sample",551 "id": 215037,552 "title": "Cannot overfit MLP on random batch sample",553 "slug": "cannot-overfit-mlp-on-random-batch-sample",554 "posts_count": 2,555 "reply_count": 0,556 "highest_post_number": 2,557 "image_url": null,558 "created_at": "2025-01-06T16:09:07.584Z",559 "last_posted_at": "2025-01-07T07:41:28.200Z",560 "bumped": true,561 "bumped_at": "2025-01-07T07:41:28.200Z",562 "archetype": "regular",563 "unseen": false,564 "pinned": false,565 "unpinned": null,566 "visible": true,567 "closed": false,568 "archived": false,569 "bookmarked": null,570 "liked": null,571 "tags_descriptions": {},572 "like_count": 0,573 "views": 56,574 "category_id": 1,575 "featured_link": null,576 "has_accepted_answer": false,577 "posters": [578 {579 "extras": null,580 "description": "Original Poster",581 "user": {582 "id": 302,583 "username": "kirk86",584 "name": "Kirk86",585 "avatar_template": "/user_avatar/discuss.pytorch.org/kirk86/{size}/151_2.png",586 "trust_level": 2587 }588 },589 {590 "extras": "latest",591 "description": "Most Recent Poster",592 "user": {593 "id": 76307,594 "username": "Tlotlo_Oepeng",595 "name": "Tlotlo Oepeng",596 "avatar_template": "/user_avatar/discuss.pytorch.org/tlotlo_oepeng/{size}/70463_2.png",597 "trust_level": 1598 }599 }600 ]601 }602 ],603 "tags_descriptions": {},604 "fancy_title": "Densenet Transfer Learning",605 "id": 7776,606 "title": "Densenet Transfer Learning",607 "posts_count": 5,608 "created_at": "2017-09-24T07:25:57.541Z",609 "views": 4321,610 "reply_count": 2,611 "like_count": 4,612 "last_posted_at": "2019-07-09T10:52:34.123Z",613 "visible": true,614 "closed": false,615 "archived": false,616 "has_summary": false,617 "archetype": "regular",618 "slug": "densenet-transfer-learning",619 "category_id": 1,620 "word_count": 367,621 "deleted_at": null,622 "user_id": 3538,623 "featured_link": null,624 "pinned_globally": false,625 "pinned_at": null,626 "pinned_until": null,627 "image_url": null,628 "slow_mode_seconds": 0,629 "draft": null,630 "draft_key": "topic_7776",631 "draft_sequence": null,632 "unpinned": null,633 "pinned": false,634 "current_post_number": 1,635 "highest_post_number": 5,636 "deleted_by": null,637 "actions_summary": [638 {639 "id": 4,640 "count": 0,641 "hidden": false,642 "can_act": false643 },644 {645 "id": 8,646 "count": 0,647 "hidden": false,648 "can_act": false649 },650 {651 "id": 10,652 "count": 0,653 "hidden": false,654 "can_act": false655 },656 {657 "id": 7,658 "count": 0,659 "hidden": false,660 "can_act": false661 }662 ],663 "chunk_size": 20,664 "bookmarked": false,665 "topic_timer": null,666 "message_bus_last_id": 0,667 "participant_count": 4,668 "show_read_indicator": false,669 "thumbnails": null,670 "slow_mode_enabled_until": null,671 "can_vote": false,672 "vote_count": 0,673 "user_voted": false,674 "discourse_zendesk_plugin_zendesk_id": null,675 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",676 "details": {677 "can_edit": false,678 "notification_level": 1,679 "participants": [680 {681 "id": 3538,682 "username": "balaji",683 "name": "balaji",684 "avatar_template": "/letter_avatar_proxy/v4/letter/b/2bfe46/{size}.png",685 "post_count": 2,686 "primary_group_name": null,687 "flair_name": null,688 "flair_url": null,689 "flair_color": null,690 "flair_bg_color": null,691 "flair_group_id": null,692 "trust_level": 1693 },694 {695 "id": 1,696 "username": "smth",697 "name": "",698 "avatar_template": "/user_avatar/discuss.pytorch.org/smth/{size}/13_2.png",699 "post_count": 1,700 "primary_group_name": null,701 "flair_name": null,702 "flair_url": null,703 "flair_color": null,704 "flair_bg_color": null,705 "flair_group_id": null,706 "admin": true,707 "moderator": true,708 "trust_level": 2709 },710 {711 "id": 7669,712 "username": "muralidharpettela",713 "name": "Muralidhar",714 "avatar_template": "/letter_avatar_proxy/v4/letter/m/71e660/{size}.png",715 "post_count": 1,716 "primary_group_name": null,717 "flair_name": null,718 "flair_url": null,719 "flair_color": null,720 "flair_bg_color": null,721 "flair_group_id": null,722 "trust_level": 1723 },724 {725 "id": 20420,726 "username": "111104",727 "name": "锦海 杨",728 "avatar_template": "/user_avatar/discuss.pytorch.org/111104/{size}/13905_2.png",729 "post_count": 1,730 "primary_group_name": null,731 "flair_name": null,732 "flair_url": null,733 "flair_color": null,734 "flair_bg_color": null,735 "flair_group_id": null,736 "trust_level": 1737 }738 ],739 "created_by": {740 "id": 3538,741 "username": "balaji",742 "name": "balaji",743 "avatar_template": "/letter_avatar_proxy/v4/letter/b/2bfe46/{size}.png"744 },745 "last_poster": {746 "id": 20420,747 "username": "111104",748 "name": "锦海 杨",749 "avatar_template": "/user_avatar/discuss.pytorch.org/111104/{size}/13905_2.png"750 },751 "links": [752 {753 "url": "https://github.com/pytorch/vision/blob/master/torchvision/models/densenet.py#L158-L159",754 "title": "vision/densenet.py at master · pytorch/vision · GitHub",755 "internal": false,756 "attachment": false,757 "reflection": false,758 "clicks": 102,759 "user_id": 1,760 "domain": "github.com",761 "root_domain": "github.com"762 }763 ]764 },765 "bookmarks": []766 },767 {768 "post_stream": {769 "posts": [770 {771 "id": 121840,772 "name": "",773 "username": "Dhorka",774 "avatar_template": "/letter_avatar_proxy/v4/letter/d/b2d939/{size}.png",775 "created_at": "2019-07-08T12:49:52.977Z",776 "cooked": "<p>I have this tensor:</p>\n<pre><code class=\"lang-auto\">tensor([[425.0000, 625.0000],\n [550.0000, 566.6667],\n [700.0000, 600.0000]])\n</code></pre>\n<p>and I want to obtain something like this:</p>\n<pre><code class=\"lang-auto\">tensor([[425.0000, 425.0000, 625.0000, 625.0000],\n [550.0000, 550.0000, 566.6667, 566.6667],\n [700.0000, 700.0000, 600.0000, 600.0000]\n</code></pre>\n<p>Is there anyway to do this efficiently?</p>",777 "post_number": 1,778 "post_type": 1,779 "posts_count": 4,780 "updated_at": "2019-07-08T12:49:52.977Z",781 "reply_count": 0,782 "reply_to_post_number": null,783 "quote_count": 0,784 "incoming_link_count": 44,785 "reads": 6,786 "readers_count": 5,787 "score": 221.2,788 "yours": false,789 "topic_id": 50013,790 "topic_slug": "repeating-a-tensor-in-intercalated-form",791 "display_username": "",792 "primary_group_name": null,793 "flair_name": null,794 "flair_url": null,795 "flair_bg_color": null,796 "flair_color": null,797 "flair_group_id": null,798 "badges_granted": [],799 "version": 1,800 "can_edit": false,801 "can_delete": false,802 "can_recover": false,803 "can_see_hidden_post": false,804 "can_wiki": false,805 "read": true,806 "user_title": null,807 "bookmarked": false,808 "actions_summary": [],809 "moderator": false,810 "admin": false,811 "staff": false,812 "user_id": 12130,813 "hidden": false,814 "trust_level": 1,815 "deleted_at": null,816 "user_deleted": false,817 "edit_reason": null,818 "can_view_edit_history": true,819 "wiki": false,820 "post_url": "/t/repeating-a-tensor-in-intercalated-form/50013/1",821 "can_accept_answer": false,822 "can_unaccept_answer": false,823 "accepted_answer": false,824 "topic_accepted_answer": null,825 "can_vote": false826 },827 {828 "id": 121855,829 "name": "",830 "username": "ptrblck",831 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",832 "created_at": "2019-07-08T14:23:14.374Z",833 "cooked": "<p>Maybe not the most elegant way, but this should work:</p>\n<pre><code class=\"lang-python\">x.unsqueeze(1).permute(0, 2, 1).repeat(1, 1, 2).view(3, 4)\n</code></pre>",834 "post_number": 2,835 "post_type": 1,836 "posts_count": 4,837 "updated_at": "2019-07-08T14:23:14.374Z",838 "reply_count": 0,839 "reply_to_post_number": null,840 "quote_count": 0,841 "incoming_link_count": 0,842 "reads": 5,843 "readers_count": 4,844 "score": 1.0,845 "yours": false,846 "topic_id": 50013,847 "topic_slug": "repeating-a-tensor-in-intercalated-form",848 "display_username": "",849 "primary_group_name": null,850 "flair_name": null,851 "flair_url": null,852 "flair_bg_color": null,853 "flair_color": null,854 "flair_group_id": null,855 "badges_granted": [],856 "version": 1,857 "can_edit": false,858 "can_delete": false,859 "can_recover": false,860 "can_see_hidden_post": false,861 "can_wiki": false,862 "read": true,863 "user_title": "",864 "bookmarked": false,865 "actions_summary": [],866 "moderator": true,867 "admin": true,868 "staff": true,869 "user_id": 3534,870 "hidden": false,871 "trust_level": 2,872 "deleted_at": null,873 "user_deleted": false,874 "edit_reason": null,875 "can_view_edit_history": true,876 "wiki": false,877 "post_url": "/t/repeating-a-tensor-in-intercalated-form/50013/2",878 "can_accept_answer": false,879 "can_unaccept_answer": false,880 "accepted_answer": false,881 "topic_accepted_answer": null882 },883 {884 "id": 121966,885 "name": "",886 "username": "Dhorka",887 "avatar_template": "/letter_avatar_proxy/v4/letter/d/b2d939/{size}.png",888 "created_at": "2019-07-09T04:35:28.684Z",889 "cooked": "<p>Thanks!! I would like to ask what is the difference between reshape, view and why sometimes view needs to be followed by the contiguous() method.</p>",890 "post_number": 3,891 "post_type": 1,892 "posts_count": 4,893 "updated_at": "2019-07-09T04:35:28.684Z",894 "reply_count": 1,895 "reply_to_post_number": null,896 "quote_count": 0,897 "incoming_link_count": 0,898 "reads": 2,899 "readers_count": 1,900 "score": 5.4,901 "yours": false,902 "topic_id": 50013,903 "topic_slug": "repeating-a-tensor-in-intercalated-form",904 "display_username": "",905 "primary_group_name": null,906 "flair_name": null,907 "flair_url": null,908 "flair_bg_color": null,909 "flair_color": null,910 "flair_group_id": null,911 "badges_granted": [],912 "version": 1,913 "can_edit": false,914 "can_delete": false,915 "can_recover": false,916 "can_see_hidden_post": false,917 "can_wiki": false,918 "read": true,919 "user_title": null,920 "bookmarked": false,921 "actions_summary": [],922 "moderator": false,923 "admin": false,924 "staff": false,925 "user_id": 12130,926 "hidden": false,927 "trust_level": 1,928 "deleted_at": null,929 "user_deleted": false,930 "edit_reason": null,931 "can_view_edit_history": true,932 "wiki": false,933 "post_url": "/t/repeating-a-tensor-in-intercalated-form/50013/3",934 "can_accept_answer": false,935 "can_unaccept_answer": false,936 "accepted_answer": false,937 "topic_accepted_answer": null938 },939 {940 "id": 122034,941 "name": "",942 "username": "ptrblck",943 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",944 "created_at": "2019-07-09T10:42:24.607Z",945 "cooked": "<p><code>.reshape</code> returns a view of the tensor it possible and a copy if necessary (<a href=\"https://pytorch.org/docs/stable/torch.html#torch.reshape\" rel=\"nofollow noopener\">docs</a>).<br>\nSome operations need contiguous tensors to use e.g. the strides of the tensor internally.<br>\nIf your tensor is non-contiguous, you’ll get an error, to avoid wrong computations and other side effects.</p>",946 "post_number": 4,947 "post_type": 1,948 "posts_count": 4,949 "updated_at": "2019-07-09T10:42:24.607Z",950 "reply_count": 0,951 "reply_to_post_number": 3,952 "quote_count": 0,953 "incoming_link_count": 0,954 "reads": 2,955 "readers_count": 1,956 "score": 0.4,957 "yours": false,958 "topic_id": 50013,959 "topic_slug": "repeating-a-tensor-in-intercalated-form",960 "display_username": "",961 "primary_group_name": null,962 "flair_name": null,963 "flair_url": null,964 "flair_bg_color": null,965 "flair_color": null,966 "flair_group_id": null,967 "badges_granted": [],968 "version": 1,969 "can_edit": false,970 "can_delete": false,971 "can_recover": false,972 "can_see_hidden_post": false,973 "can_wiki": false,974 "link_counts": [975 {976 "url": "https://pytorch.org/docs/stable/torch.html#torch.reshape",977 "internal": false,978 "reflection": false,979 "title": "torch — PyTorch master documentation",980 "clicks": 0981 }982 ],983 "read": true,984 "user_title": "",985 "reply_to_user": {986 "id": 12130,987 "username": "Dhorka",988 "name": "",989 "avatar_template": "/letter_avatar_proxy/v4/letter/d/b2d939/{size}.png"990 },991 "bookmarked": false,992 "actions_summary": [],993 "moderator": true,994 "admin": true,995 "staff": true,996 "user_id": 3534,997 "hidden": false,998 "trust_level": 2,999 "deleted_at": null,1000 "user_deleted": false,1001 "edit_reason": null,1002 "can_view_edit_history": true,1003 "wiki": false,1004 "post_url": "/t/repeating-a-tensor-in-intercalated-form/50013/4",1005 "can_accept_answer": false,1006 "can_unaccept_answer": false,1007 "accepted_answer": false,1008 "topic_accepted_answer": null1009 }1010 ],1011 "stream": [1012 121840,1013 121855,1014 121966,1015 1220341016 ]1017 },1018 "timeline_lookup": [1019 [1020 1,1021 23021022 ],1023 [1024 2,1025 23011026 ]1027 ],1028 "suggested_topics": [1029 {1030 "fancy_title": "Will a tensor still be in pinned memory which is stacked by two pinned memory",1031 "id": 218006,1032 "title": "Will a tensor still be in pinned memory which is stacked by two pinned memory",1033 "slug": "will-a-tensor-still-be-in-pinned-memory-which-is-stacked-by-two-pinned-memory",1034 "posts_count": 2,1035 "reply_count": 0,1036 "highest_post_number": 2,1037 "image_url": null,1038 "created_at": "2025-03-19T02:21:20.615Z",1039 "last_posted_at": "2025-03-19T15:36:03.413Z",1040 "bumped": true,1041 "bumped_at": "2025-03-19T15:36:03.413Z",1042 "archetype": "regular",1043 "unseen": false,1044 "pinned": false,1045 "unpinned": null,1046 "visible": true,1047 "closed": false,1048 "archived": false,1049 "bookmarked": null,1050 "liked": null,1051 "tags_descriptions": {},1052 "like_count": 0,1053 "views": 12,1054 "category_id": 1,1055 "featured_link": null,1056 "has_accepted_answer": false,1057 "posters": [1058 {1059 "extras": null,1060 "description": "Original Poster",1061 "user": {1062 "id": 29441,1063 "username": "Igo312",1064 "name": "Igo312",1065 "avatar_template": "/user_avatar/discuss.pytorch.org/igo312/{size}/22283_2.png",1066 "trust_level": 11067 }1068 },1069 {1070 "extras": "latest",1071 "description": "Most Recent Poster",1072 "user": {1073 "id": 3534,1074 "username": "ptrblck",1075 "name": "",1076 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",1077 "admin": true,1078 "moderator": true,1079 "trust_level": 21080 }1081 }1082 ]1083 },1084 {1085 "fancy_title": "Question about PyTorch and TensorFlow math",1086 "id": 214022,1087 "title": "Question about PyTorch and TensorFlow math",1088 "slug": "question-about-pytorch-and-tensorflow-math",1089 "posts_count": 2,1090 "reply_count": 0,1091 "highest_post_number": 2,1092 "image_url": null,1093 "created_at": "2024-12-10T04:20:11.694Z",1094 "last_posted_at": "2024-12-10T13:20:30.605Z",1095 "bumped": true,1096 "bumped_at": "2024-12-10T13:20:30.605Z",1097 "archetype": "regular",1098 "unseen": false,1099 "pinned": false,1100 "unpinned": null,1101 "visible": true,1102 "closed": false,1103 "archived": false,1104 "bookmarked": null,1105 "liked": null,1106 "tags_descriptions": {},1107 "like_count": 0,1108 "views": 163,1109 "category_id": 1,1110 "featured_link": null,1111 "has_accepted_answer": false,1112 "posters": [1113 {1114 "extras": null,1115 "description": "Original Poster",1116 "user": {1117 "id": 81418,1118 "username": "Aosmgpem_Ipsnagpisne",1119 "name": "Aosmgpem Ipsnagpisne",1120 "avatar_template": "/user_avatar/discuss.pytorch.org/aosmgpem_ipsnagpisne/{size}/72552_2.png",1121 "trust_level": 01122 }1123 },1124 {1125 "extras": "latest",1126 "description": "Most Recent Poster",1127 "user": {1128 "id": 3534,1129 "username": "ptrblck",1130 "name": "",1131 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",1132 "admin": true,1133 "moderator": true,1134 "trust_level": 21135 }1136 }1137 ]1138 },1139 {1140 "fancy_title": "Inference with only certain layers of a model",1141 "id": 214520,1142 "title": "Inference with only certain layers of a model",1143 "slug": "inference-with-only-certain-layers-of-a-model",1144 "posts_count": 9,1145 "reply_count": 7,1146 "highest_post_number": 9,1147 "image_url": null,1148 "created_at": "2024-12-21T23:42:29.834Z",1149 "last_posted_at": "2024-12-31T17:09:54.008Z",1150 "bumped": true,1151 "bumped_at": "2024-12-31T17:09:54.008Z",1152 "archetype": "regular",1153 "unseen": false,1154 "pinned": false,1155 "unpinned": null,1156 "visible": true,1157 "closed": false,1158 "archived": false,1159 "bookmarked": null,1160 "liked": null,1161 "tags_descriptions": {},1162 "like_count": 8,1163 "views": 163,1164 "category_id": 1,1165 "featured_link": null,1166 "has_accepted_answer": false,1167 "posters": [1168 {1169 "extras": "latest",1170 "description": "Original Poster, Most Recent Poster",1171 "user": {1172 "id": 81645,1173 "username": "comradepepega",1174 "name": "",1175 "avatar_template": "/user_avatar/discuss.pytorch.org/comradepepega/{size}/74666_2.png",1176 "trust_level": 11177 }1178 },1179 {1180 "extras": null,1181 "description": "Frequent Poster",1182 "user": {1183 "id": 41396,1184 "username": "soulitzer",1185 "name": "",1186 "avatar_template": "/letter_avatar_proxy/v4/letter/s/839c29/{size}.png",1187 "trust_level": 21188 }1189 }1190 ]1191 },1192 {1193 "fancy_title": "PyTorch + CUDA on python:3.11-bullseye",1194 "id": 217698,1195 "title": "PyTorch + CUDA on python:3.11-bullseye",1196 "slug": "pytorch-cuda-on-python-3-11-bullseye",1197 "posts_count": 1,1198 "reply_count": 0,1199 "highest_post_number": 1,1200 "image_url": null,