CoolFace
Datasetpublic

Anurag1734/cuda-error-resolution-analysis

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes7downloads
topics_batch_189.json57458 linesDownload Raw Back to raw
1[2  {3    "post_stream": {4      "posts": [5        {6          "id": 373043,7          "name": "Talha Anwar",8          "username": "talhaanwarch",9          "avatar_template": "/user_avatar/discuss.pytorch.org/talhaanwarch/{size}/26568_2.png",10          "created_at": "2022-11-02T15:34:38.665Z",11          "cooked": "<p>Hi. I am passing an input of shape <code>torch.Size([6, 8, 3, 16, 120, 120])</code> to 3D CNN + GRU architecture<br>\n. I have trained model with shape <code>torch.Size([4, 8, 3, 16, 120, 120])</code> What i think the first index is a batch size and it can be variable. But i am not sure why changing it is throwing error.</p>\n<p>This is my forward function. I am using batch first in GRU layer</p>\n<pre><code class=\"lang-auto\">x=x.reshape(-1,*x.shape[2::])\nx=self.video_model(x.float())\nx=x.reshape(4,-1,x.shape[1])\nx,x1=self.gru(x.permute(0,2,1))\n</code></pre>",12          "post_number": 1,13          "post_type": 1,14          "posts_count": 1,15          "updated_at": "2022-11-02T15:34:38.665Z",16          "reply_count": 0,17          "reply_to_post_number": null,18          "quote_count": 0,19          "incoming_link_count": 41,20          "reads": 5,21          "readers_count": 4,22          "score": 206.0,23          "yours": false,24          "topic_id": 165038,25          "topic_slug": "runtimeerror-input-size-1-must-be-equal-to-input-size-3dcnn-gru",26          "display_username": "Talha Anwar",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          "read": true,41          "user_title": null,42          "bookmarked": false,43          "actions_summary": [],44          "moderator": false,45          "admin": false,46          "staff": false,47          "user_id": 24987,48          "hidden": false,49          "trust_level": 2,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/runtimeerror-input-size-1-must-be-equal-to-input-size-3dcnn-gru/165038/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      "stream": [64        37304365      ]66    },67    "timeline_lookup": [68      [69        1,70        108871      ]72    ],73    "suggested_topics": [74      {75        "fancy_title": "Pytorch DDP having memory issues",76        "id": 217453,77        "title": "Pytorch DDP having memory issues",78        "slug": "pytorch-ddp-having-memory-issues",79        "posts_count": 3,80        "reply_count": 1,81        "highest_post_number": 3,82        "image_url": null,83        "created_at": "2025-03-04T23:35:38.268Z",84        "last_posted_at": "2025-03-06T16:10:34.951Z",85        "bumped": true,86        "bumped_at": "2025-03-06T16:10:34.951Z",87        "archetype": "regular",88        "unseen": false,89        "pinned": false,90        "unpinned": null,91        "visible": true,92        "closed": false,93        "archived": false,94        "bookmarked": null,95        "liked": null,96        "tags_descriptions": {},97        "like_count": 0,98        "views": 204,99        "category_id": 5,100        "featured_link": null,101        "has_accepted_answer": false,102        "posters": [103          {104            "extras": "latest",105            "description": "Original Poster, Most Recent Poster",106            "user": {107              "id": 83068,108              "username": "tg567",109              "name": "",110              "avatar_template": "/user_avatar/discuss.pytorch.org/tg567/{size}/72734_2.png",111              "trust_level": 1112            }113          },114          {115            "extras": null,116            "description": "Frequent Poster",117            "user": {118              "id": 3534,119              "username": "ptrblck",120              "name": "",121              "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",122              "admin": true,123              "moderator": true,124              "trust_level": 2125            }126          }127        ]128      },129      {130        "fancy_title": "Yolo Neural Layer",131        "id": 212691,132        "title": "Yolo Neural Layer",133        "slug": "yolo-neural-layer",134        "posts_count": 1,135        "reply_count": 0,136        "highest_post_number": 1,137        "image_url": null,138        "created_at": "2024-11-08T08:05:48.745Z",139        "last_posted_at": "2024-11-08T08:05:48.792Z",140        "bumped": true,141        "bumped_at": "2024-11-08T08:05:48.792Z",142        "archetype": "regular",143        "unseen": false,144        "pinned": false,145        "unpinned": null,146        "visible": true,147        "closed": false,148        "archived": false,149        "bookmarked": null,150        "liked": null,151        "tags_descriptions": {},152        "like_count": 0,153        "views": 114,154        "category_id": 5,155        "featured_link": null,156        "has_accepted_answer": false,157        "posters": [158          {159            "extras": "latest single",160            "description": "Original Poster, Most Recent Poster",161            "user": {162              "id": 80766,163              "username": "coded_bias_007",164              "name": "James",165              "avatar_template": "/letter_avatar_proxy/v4/letter/c/dbc845/{size}.png",166              "trust_level": 0167            }168          }169        ]170      },171      {172        "fancy_title": "Switching from &ldquo;model.eval()&rdquo; to &ldquo;model.train()&rdquo; severely degrades performance",173        "id": 215519,174        "title": "Switching from \"model.eval()\" to \"model.train()\" severely degrades performance",175        "slug": "switching-from-model-eval-to-model-train-severely-degrades-performance",176        "posts_count": 1,177        "reply_count": 0,178        "highest_post_number": 1,179        "image_url": null,180        "created_at": "2025-01-17T14:54:50.152Z",181        "last_posted_at": "2025-01-17T14:54:50.195Z",182        "bumped": true,183        "bumped_at": "2025-01-20T06:05:12.301Z",184        "archetype": "regular",185        "unseen": false,186        "pinned": false,187        "unpinned": null,188        "visible": true,189        "closed": false,190        "archived": false,191        "bookmarked": null,192        "liked": null,193        "tags_descriptions": {},194        "like_count": 0,195        "views": 120,196        "category_id": 5,197        "featured_link": null,198        "has_accepted_answer": false,199        "posters": [200          {201            "extras": "latest single",202            "description": "Original Poster, Most Recent Poster",203            "user": {204              "id": 76983,205              "username": "cloudydory",206              "name": "",207              "avatar_template": "/letter_avatar_proxy/v4/letter/c/dfb087/{size}.png",208              "trust_level": 1209            }210          }211        ]212      },213      {214        "fancy_title": "Faster Vit Hierarchical Attention",215        "id": 214037,216        "title": "Faster Vit Hierarchical Attention",217        "slug": "faster-vit-hierarchical-attention",218        "posts_count": 1,219        "reply_count": 0,220        "highest_post_number": 1,221        "image_url": null,222        "created_at": "2024-12-10T08:36:29.626Z",223        "last_posted_at": "2024-12-10T08:36:29.684Z",224        "bumped": true,225        "bumped_at": "2024-12-10T08:36:29.684Z",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": 0,237        "views": 127,238        "category_id": 5,239        "featured_link": null,240        "has_accepted_answer": false,241        "posters": [242          {243            "extras": "latest single",244            "description": "Original Poster, Most Recent Poster",245            "user": {246              "id": 81424,247              "username": "hussainmir05",248              "name": "Hussain mir",249              "avatar_template": "/user_avatar/discuss.pytorch.org/hussainmir05/{size}/72721_2.png",250              "trust_level": 0251            }252          }253        ]254      },255      {256        "fancy_title": "Gradient and the tensor dtype inconsistencies",257        "id": 219066,258        "title": "Gradient and the tensor dtype inconsistencies",259        "slug": "gradient-and-the-tensor-dtype-inconsistencies",260        "posts_count": 4,261        "reply_count": 1,262        "highest_post_number": 4,263        "image_url": null,264        "created_at": "2025-04-14T14:07:44.627Z",265        "last_posted_at": "2025-04-15T14:13:39.474Z",266        "bumped": true,267        "bumped_at": "2025-04-15T14:13:39.474Z",268        "archetype": "regular",269        "unseen": false,270        "pinned": false,271        "unpinned": null,272        "visible": true,273        "closed": false,274        "archived": false,275        "bookmarked": null,276        "liked": null,277        "tags_descriptions": {},278        "like_count": 0,279        "views": 126,280        "category_id": 5,281        "featured_link": null,282        "has_accepted_answer": false,283        "posters": [284          {285            "extras": null,286            "description": "Original Poster",287            "user": {288              "id": 29433,289              "username": "cltexe",290              "name": "Omer Faruk Soylemez",291              "avatar_template": "/user_avatar/discuss.pytorch.org/cltexe/{size}/41817_2.png",292              "trust_level": 1293            }294          },295          {296            "extras": null,297            "description": "Frequent Poster",298            "user": {299              "id": 77908,300              "username": "mycul",301              "name": "",302              "avatar_template": "/user_avatar/discuss.pytorch.org/mycul/{size}/72394_2.png",303              "trust_level": 2304            }305          },306          {307            "extras": "latest",308            "description": "Most Recent Poster",309            "user": {310              "id": 3534,311              "username": "ptrblck",312              "name": "",313              "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",314              "admin": true,315              "moderator": true,316              "trust_level": 2317            }318          }319        ]320      }321    ],322    "tags_descriptions": {},323    "fancy_title": "RuntimeError: input.size(-1) must be equal to input_size. 3DCNN+GRU",324    "id": 165038,325    "title": "RuntimeError: input.size(-1) must be equal to input_size. 3DCNN+GRU",326    "posts_count": 1,327    "created_at": "2022-11-02T15:34:38.577Z",328    "views": 449,329    "reply_count": 0,330    "like_count": 0,331    "last_posted_at": "2022-11-02T15:34:38.665Z",332    "visible": true,333    "closed": false,334    "archived": false,335    "has_summary": false,336    "archetype": "regular",337    "slug": "runtimeerror-input-size-1-must-be-equal-to-input-size-3dcnn-gru",338    "category_id": 5,339    "word_count": 103,340    "deleted_at": null,341    "user_id": 24987,342    "featured_link": null,343    "pinned_globally": false,344    "pinned_at": null,345    "pinned_until": null,346    "image_url": null,347    "slow_mode_seconds": 0,348    "draft": null,349    "draft_key": "topic_165038",350    "draft_sequence": null,351    "unpinned": null,352    "pinned": false,353    "current_post_number": 1,354    "highest_post_number": 1,355    "deleted_by": null,356    "actions_summary": [357      {358        "id": 4,359        "count": 0,360        "hidden": false,361        "can_act": false362      },363      {364        "id": 8,365        "count": 0,366        "hidden": false,367        "can_act": false368      },369      {370        "id": 10,371        "count": 0,372        "hidden": false,373        "can_act": false374      },375      {376        "id": 7,377        "count": 0,378        "hidden": false,379        "can_act": false380      }381    ],382    "chunk_size": 20,383    "bookmarked": false,384    "topic_timer": null,385    "message_bus_last_id": 0,386    "participant_count": 1,387    "show_read_indicator": false,388    "thumbnails": null,389    "slow_mode_enabled_until": null,390    "can_vote": false,391    "vote_count": 0,392    "user_voted": false,393    "discourse_zendesk_plugin_zendesk_id": null,394    "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",395    "details": {396      "can_edit": false,397      "notification_level": 1,398      "participants": [399        {400          "id": 24987,401          "username": "talhaanwarch",402          "name": "Talha Anwar",403          "avatar_template": "/user_avatar/discuss.pytorch.org/talhaanwarch/{size}/26568_2.png",404          "post_count": 1,405          "primary_group_name": null,406          "flair_name": null,407          "flair_url": null,408          "flair_color": null,409          "flair_bg_color": null,410          "flair_group_id": null,411          "trust_level": 2412        }413      ],414      "created_by": {415        "id": 24987,416        "username": "talhaanwarch",417        "name": "Talha Anwar",418        "avatar_template": "/user_avatar/discuss.pytorch.org/talhaanwarch/{size}/26568_2.png"419      },420      "last_poster": {421        "id": 24987,422        "username": "talhaanwarch",423        "name": "Talha Anwar",424        "avatar_template": "/user_avatar/discuss.pytorch.org/talhaanwarch/{size}/26568_2.png"425      }426    },427    "bookmarks": []428  },429  {430    "post_stream": {431      "posts": [432        {433          "id": 373020,434          "name": "",435          "username": "Mhtsf",436          "avatar_template": "/letter_avatar_proxy/v4/letter/m/5f8ce5/{size}.png",437          "created_at": "2022-11-02T11:33:49.195Z",438          "cooked": "<p>Hi,</p>\n<p>I’m trying to create a model that infers two parameters from a string of data. To do this I had to create a custom data loader for my data files. Data file format is 10538 data points in a .csv file. Due to the need for a custom data loader, I am unable to quite get the definition of the training function correct and keep getting errors. I have included my code:</p>\n<pre><code class=\"lang-auto\">import torch\nfrom torch.utils.data import Dataset, DataLoader\nfrom torch.utils.data.sampler import SubsetRandomSampler\nfrom torch import nn\nimport os\nimport pandas as pd\nimport numpy as np\nfrom numpy import genfromtxt\nfrom scipy import special as sp\nimport random\nimport shutil\n\n# Define Custom Dataset to contain all the training data\nclass CustomDataset(Dataset):\n    def __init__(self, annotations_file, data_dir):\n        self.labels = pd.read_csv(annotations_file)\n        self.data_dir = data_dir\n\n    def __len__(self):\n        return len(self.labels)\n\n    def __getitem__(self, idx):\n        data_path = os.path.join(self.data_dir, self.labels.iloc[idx, 0])\n        data = torch.from_numpy(genfromtxt(data_path, delimiter=','))\n        mu = self.labels.iloc[idx,1]\n        sigma = self.labels.iloc[idx,2]\n        return data, mu, sigma\n\n# Parameters for taking a random sample of the data for validation\ndataset = CustomDataset(\"data/labels.csv\", \"data\")\nbatch_size = 64\nvalidation_split = 0.25\nshuffle = True\nrandom_seed = 42\n\nindices = list(range(dataset.__len__()))\nsplit = int(np.floor(validation_split * dataset.__len__()))\nif shuffle :\n    np.random.seed(random_seed)\n    np.random.shuffle(indices)\ntrain_indices, val_indices = indices[:split], indices[split:]\n\n# Creating PT data samplers and loaders:\ntrain_sampler = SubsetRandomSampler(train_indices)\nvalid_sampler = SubsetRandomSampler(val_indices)\n\ntrain_loader = DataLoader(dataset, batch_size=batch_size, sampler=train_sampler)\nvalidation_loader = DataLoader(dataset, batch_size=batch_size, sampler=valid_sampler)\n\n# Ensure the GPU is available\ndevice = \"cuda\" if torch.cuda.is_available() else \"cpu\"\nprint(f\"Using {device} device\")\n\n# Design Neural Network for training\nclass NeuralNetwork(nn.Module):\n    def __init__(self):\n        super(NeuralNetwork, self).__init__()\n        self.flatten = nn.Flatten()\n        self.linear_relu_stack = nn.Sequential(\n            nn.Linear(10538, 1054),\n            nn.ReLU(),\n            nn.Linear(1054, 106),\n            nn.ReLU(),\n            nn.Linear(106, 11),\n            nn.ReLU(),\n            nn.Linear(11, 2),\n        )\n    \n    def forward(self, x):\n        x = self.flatten(x)\n        x = x.float()\n        logits = self.linear_relu_stack(x)\n        return logits\n\nmodel = NeuralNetwork().to(device).float()\n\n# Define Model Loss Function and Optimizer\nloss_fn = nn.MSELoss()\n\noptimizer = torch.optim.SGD(model.parameters(), lr=1e-3)\n\n# Define the training method for the Neural Network\ndef train(dataloader, model, loss_fn, optimizer):\n    size = len(dataloader.dataset)\n    model.train()\n    for batch, (X, mu, sigma) in enumerate(dataloader):\n        X, mu, sigma = X.to(device), mu.to(device), sigma.to(device)\n\n        # Compute Prediction Error\n        pred = model(X)\n        target = torch.column_stack((mu,sigma))\n        loss = loss_fn(pred, target)\n\n        # Backpropogation\n        optimizer.zero_grad()\n        loss.backward()\n        optimizer.step()\n\n        if batch % 100 == 0:\n            loss, current = loss.item(), batch * len(X)\n            print(f\"loss: {loss:&gt;7f} [{current:&gt;5d}/{size:&gt;5d}]\")\n\n# Define the testing method for the Neural Network\ndef test(dataloader, model, loss_fn):\n    size = len(dataloader.dataset)\n    num_bathces = len(dataloader)\n    model.eval()\n    test_loss, correct = 0, 0\n    with torch.no_grad():\n        for X, y in dataloader:\n            X, y = X.to(device), y.to(device)\n            pred = model(X)\n            test_loss += loss_fn(pred, y).item()\n            correct += (pred.argmax(1) == y).type(torch.float).sum().item()\n    test_loss /= num_batches\n    correct /= size\n    print(f\"Test Error: \\n Accuracy: {(100 * correct):&gt;0.1f}%, Avg Loss: {test_loss:&gt;8f} \\n\")\n\n# Train the Model\nepochs = 10\nfor t in range(epochs):\n    print(f\"Epoch {t+1}\\n------------------------------\")\n    train(train_loader, model, loss_fn, optimizer)\n    test(validation_loader, model, loss_fn)\nprint(\"Done!\")\n\ntorch.save(model.state_dict(), \"model.pth\")\nprint(\"Saved PyTorch Morch State to model.pth\")\n</code></pre>\n<p>The initial error I was receiving was that <code>pred = model(X)</code> was expecting a float value but receiving double. This was solved by casting the model and the values to float: <code>model = NeuralNetwork().to(device).float()</code>. However, now the error I receive is:</p>\n<pre><code class=\"lang-auto\">Traceback (most recent call last):\n  File \"DataGen.py\", line 123, in &lt;module&gt;\n    print(f\"Epoch {t+1}\\n------------------------------\")\n  File \"DataGen.py\", line 96, in train\n    optimizer.zero_grad()\n  File \"D:\\Documents\\Python\\.venvs\\virtual1\\lib\\site-packages\\torch\\_tensor.py\", line 396, in backward\n    torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)\n  File \"D:\\Documents\\Python\\.venvs\\virtual1\\lib\\site-packages\\torch\\autograd\\__init__.py\", line 173, in backward\n    Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass\nRuntimeError: Found dtype Double but expected Float\n</code></pre>\n<p>And I am unsure what to make of it, why is pytorch outputting double type data if it is expecting float type? I would ideally not have to continue casting to the correct type, is there an underlying solution? I am very new to Pytorch, so apologise if this seems trivial.</p>",439          "post_number": 1,440          "post_type": 1,441          "posts_count": 2,442          "updated_at": "2022-11-02T11:53:26.668Z",443          "reply_count": 0,444          "reply_to_post_number": null,445          "quote_count": 0,446          "incoming_link_count": 20,447          "reads": 10,448          "readers_count": 9,449          "score": 102.0,450          "yours": false,451          "topic_id": 165019,452          "topic_slug": "cant-get-my-training-function-right",453          "display_username": "",454          "primary_group_name": null,455          "flair_name": null,456          "flair_url": null,457          "flair_bg_color": null,458          "flair_color": null,459          "flair_group_id": null,460          "badges_granted": [],461          "version": 2,462          "can_edit": false,463          "can_delete": false,464          "can_recover": false,465          "can_see_hidden_post": false,466          "can_wiki": false,467          "read": true,468          "user_title": null,469          "bookmarked": false,470          "actions_summary": [],471          "moderator": false,472          "admin": false,473          "staff": false,474          "user_id": 60628,475          "hidden": false,476          "trust_level": 1,477          "deleted_at": null,478          "user_deleted": false,479          "edit_reason": null,480          "can_view_edit_history": true,481          "wiki": false,482          "post_url": "/t/cant-get-my-training-function-right/165019/1",483          "can_accept_answer": false,484          "can_unaccept_answer": false,485          "accepted_answer": false,486          "topic_accepted_answer": true,487          "can_vote": false488        },489        {490          "id": 373032,491          "name": "",492          "username": "Mhtsf",493          "avatar_template": "/letter_avatar_proxy/v4/letter/m/5f8ce5/{size}.png",494          "created_at": "2022-11-02T14:07:55.819Z",495          "cooked": "<p>This has been solved by casting the <code>target</code> tensor to float32 by: <code>target = torch.column_stack((mu, sigma)).to(torch.float32)</code></p>",496          "post_number": 2,497          "post_type": 1,498          "posts_count": 2,499          "updated_at": "2022-11-02T14:07:55.819Z",500          "reply_count": 0,501          "reply_to_post_number": null,502          "quote_count": 0,503          "incoming_link_count": 0,504          "reads": 8,505          "readers_count": 7,506          "score": 1.6,507          "yours": false,508          "topic_id": 165019,509          "topic_slug": "cant-get-my-training-function-right",510          "display_username": "",511          "primary_group_name": null,512          "flair_name": null,513          "flair_url": null,514          "flair_bg_color": null,515          "flair_color": null,516          "flair_group_id": null,517          "badges_granted": [],518          "version": 1,519          "can_edit": false,520          "can_delete": false,521          "can_recover": false,522          "can_see_hidden_post": false,523          "can_wiki": false,524          "read": true,525          "user_title": null,526          "bookmarked": false,527          "actions_summary": [],528          "moderator": false,529          "admin": false,530          "staff": false,531          "user_id": 60628,532          "hidden": false,533          "trust_level": 1,534          "deleted_at": null,535          "user_deleted": false,536          "edit_reason": null,537          "can_view_edit_history": true,538          "wiki": false,539          "post_url": "/t/cant-get-my-training-function-right/165019/2",540          "can_accept_answer": false,541          "can_unaccept_answer": false,542          "accepted_answer": true,543          "topic_accepted_answer": true544        }545      ],546      "stream": [547        373020,548        373032549      ]550    },551    "timeline_lookup": [552      [553        1,554        1088555      ]556    ],557    "suggested_topics": [558      {559        "fancy_title": "Custom Fold and Unfold",560        "id": 219793,561        "title": "Custom Fold and Unfold",562        "slug": "custom-fold-and-unfold",563        "posts_count": 1,564        "reply_count": 0,565        "highest_post_number": 1,566        "image_url": null,567        "created_at": "2025-05-06T06:56:40.685Z",568        "last_posted_at": "2025-05-06T06:56:40.765Z",569        "bumped": true,570        "bumped_at": "2025-05-06T06:56:40.765Z",571        "archetype": "regular",572        "unseen": false,573        "pinned": false,574        "unpinned": null,575        "visible": true,576        "closed": false,577        "archived": false,578        "bookmarked": null,579        "liked": null,580        "tags_descriptions": {},581        "like_count": 0,582        "views": 39,583        "category_id": 33,584        "featured_link": null,585        "has_accepted_answer": false,586        "posters": [587          {588            "extras": "latest single",589            "description": "Original Poster, Most Recent Poster",590            "user": {591              "id": 84158,592              "username": "AnomUser8765",593              "name": "",594              "avatar_template": "/user_avatar/discuss.pytorch.org/anomuser8765/{size}/74623_2.png",595              "trust_level": 0596            }597          }598        ]599      },600      {601        "fancy_title": "How to address pretrained facenet overfitting for facial verification?",602        "id": 221844,603        "title": "How to address pretrained facenet overfitting for facial verification?",604        "slug": "how-to-address-pretrained-facenet-overfitting-for-facial-verification",605        "posts_count": 1,606        "reply_count": 0,607        "highest_post_number": 1,608        "image_url": null,609        "created_at": "2025-07-27T03:47:21.871Z",610        "last_posted_at": "2025-07-27T03:47:21.913Z",611        "bumped": true,612        "bumped_at": "2025-07-27T04:56:09.339Z",613        "archetype": "regular",614        "unseen": false,615        "pinned": false,616        "unpinned": null,617        "visible": true,618        "closed": false,619        "archived": false,620        "bookmarked": null,621        "liked": null,622        "tags_descriptions": {},623        "like_count": 0,624        "views": 32,625        "category_id": 33,626        "featured_link": null,627        "has_accepted_answer": false,628        "posters": [629          {630            "extras": "latest single",631            "description": "Original Poster, Most Recent Poster",632            "user": {633              "id": 83600,634              "username": "Jayasuryan",635              "name": " ",636              "avatar_template": "/user_avatar/discuss.pytorch.org/jayasuryan/{size}/76466_2.png",637              "trust_level": 1638            }639          }640        ]641      },642      {643        "fancy_title": "Matrix factorisation using gradient descent: performing singular value decomposition on a toy dataset",644        "id": 214535,645        "title": "Matrix factorisation using gradient descent: performing singular value decomposition on a toy dataset",646        "slug": "matrix-factorisation-using-gradient-descent-performing-singular-value-decomposition-on-a-toy-dataset",647        "posts_count": 2,648        "reply_count": 0,649        "highest_post_number": 2,650        "image_url": null,651        "created_at": "2024-12-22T11:05:16.861Z",652        "last_posted_at": "2024-12-25T04:22:07.402Z",653        "bumped": true,654        "bumped_at": "2024-12-25T04:22:07.402Z",655        "archetype": "regular",656        "unseen": false,657        "pinned": false,658        "unpinned": null,659        "visible": true,660        "closed": false,661        "archived": false,662        "bookmarked": null,663        "liked": null,664        "tags_descriptions": {},665        "like_count": 0,666        "views": 69,667        "category_id": 33,668        "featured_link": null,669        "has_accepted_answer": false,670        "posters": [671          {672            "extras": null,673            "description": "Original Poster",674            "user": {675              "id": 81659,676              "username": "akinolawilson",677              "name": "Akin Wilson",678              "avatar_template": "/user_avatar/discuss.pytorch.org/akinolawilson/{size}/74679_2.png",679              "trust_level": 0680            }681          },682          {683            "extras": "latest",684            "description": "Most Recent Poster",685            "user": {686              "id": 18088,687              "username": "KFrank",688              "name": "K. Frank",689              "avatar_template": "/letter_avatar_proxy/v4/letter/k/ecb155/{size}.png",690              "trust_level": 2691            }692          }693        ]694      },695      {696        "fancy_title": "Back propagation of a time series with LSTM",697        "id": 217299,698        "title": "Back propagation of a time series with LSTM",699        "slug": "back-propagation-of-a-time-series-with-lstm",700        "posts_count": 1,701        "reply_count": 0,702        "highest_post_number": 1,703        "image_url": null,704        "created_at": "2025-02-28T16:02:32.926Z",705        "last_posted_at": "2025-02-28T16:02:32.969Z",706        "bumped": true,707        "bumped_at": "2025-02-28T16:07:05.185Z",708        "archetype": "regular",709        "unseen": false,710        "pinned": false,711        "unpinned": null,712        "visible": true,713        "closed": false,714        "archived": false,715        "bookmarked": null,716        "liked": null,717        "tags_descriptions": {},718        "like_count": 0,719        "views": 42,720        "category_id": 33,721        "featured_link": null,722        "has_accepted_answer": false,723        "posters": [724          {725            "extras": "latest single",726            "description": "Original Poster, Most Recent Poster",727            "user": {728              "id": 82998,729              "username": "davide",730              "name": "davide",731              "avatar_template": "/user_avatar/discuss.pytorch.org/davide/{size}/75927_2.png",732              "trust_level": 1733            }734          }735        ]736      },737      {738        "fancy_title": "Guiding Image Generation in Diffusion Models with PyTorch",739        "id": 222779,740        "title": "Guiding Image Generation in Diffusion Models with PyTorch",741        "slug": "guiding-image-generation-in-diffusion-models-with-pytorch",742        "posts_count": 1,743        "reply_count": 0,744        "highest_post_number": 1,745        "image_url": "https://discuss.pytorch.org/uploads/default/optimized/3X/3/2/323fe8fb8f2e38da6ed4f9556d3323002d1aa8cc_2_1024x261.jpeg",746        "created_at": "2025-08-31T09:26:21.475Z",747        "last_posted_at": "2025-08-31T09:26:21.529Z",748        "bumped": true,749        "bumped_at": "2025-08-31T09:53:50.124Z",750        "archetype": "regular",751        "unseen": false,752        "pinned": false,753        "unpinned": null,754        "visible": true,755        "closed": false,756        "archived": false,757        "bookmarked": null,758        "liked": null,759        "tags_descriptions": {},760        "like_count": 0,761        "views": 24,762        "category_id": 33,763        "featured_link": null,764        "has_accepted_answer": false,765        "posters": [766          {767            "extras": "latest single",768            "description": "Original Poster, Most Recent Poster",769            "user": {770              "id": 18645,771              "username": "sid-ls",772              "name": "sid ls ",773              "avatar_template": "/user_avatar/discuss.pytorch.org/sid-ls/{size}/12123_2.png",774              "trust_level": 2775            }776          }777        ]778      }779    ],780    "tags_descriptions": {},781    "fancy_title": "Can&rsquo;t get my training function right",782    "id": 165019,783    "title": "Can't get my training function right",784    "posts_count": 2,785    "created_at": "2022-11-02T11:33:49.092Z",786    "views": 598,787    "reply_count": 0,788    "like_count": 0,789    "last_posted_at": "2022-11-02T14:07:55.819Z",790    "visible": true,791    "closed": false,792    "archived": false,793    "has_summary": false,794    "archetype": "regular",795    "slug": "cant-get-my-training-function-right",796    "category_id": 33,797    "word_count": 776,798    "deleted_at": null,799    "user_id": 60628,800    "featured_link": null,801    "pinned_globally": false,802    "pinned_at": null,803    "pinned_until": null,804    "image_url": null,805    "slow_mode_seconds": 0,806    "draft": null,807    "draft_key": "topic_165019",808    "draft_sequence": null,809    "unpinned": null,810    "pinned": false,811    "current_post_number": 1,812    "highest_post_number": 2,813    "deleted_by": null,814    "actions_summary": [815      {816        "id": 4,817        "count": 0,818        "hidden": false,819        "can_act": false820      },821      {822        "id": 8,823        "count": 0,824        "hidden": false,825        "can_act": false826      },827      {828        "id": 10,829        "count": 0,830        "hidden": false,831        "can_act": false832      },833      {834        "id": 7,835        "count": 0,836        "hidden": false,837        "can_act": false838      }839    ],840    "chunk_size": 20,841    "bookmarked": false,842    "topic_timer": null,843    "message_bus_last_id": 0,844    "participant_count": 1,845    "show_read_indicator": false,846    "thumbnails": null,847    "slow_mode_enabled_until": null,848    "accepted_answer": {849      "post_number": 2,850      "username": "Mhtsf",851      "name": "",852      "excerpt": "This has been solved by casting the target tensor to float32 by: target = torch.column_stack((mu, sigma)).to(torch.float32)"853    },854    "can_vote": false,855    "vote_count": 0,856    "user_voted": false,857    "discourse_zendesk_plugin_zendesk_id": null,858    "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",859    "details": {860      "can_edit": false,861      "notification_level": 1,862      "participants": [863        {864          "id": 60628,865          "username": "Mhtsf",866          "name": "",867          "avatar_template": "/letter_avatar_proxy/v4/letter/m/5f8ce5/{size}.png",868          "post_count": 2,869          "primary_group_name": null,870          "flair_name": null,871          "flair_url": null,872          "flair_color": null,873          "flair_bg_color": null,874          "flair_group_id": null,875          "trust_level": 1876        }877      ],878      "created_by": {879        "id": 60628,880        "username": "Mhtsf",881        "name": "",882        "avatar_template": "/letter_avatar_proxy/v4/letter/m/5f8ce5/{size}.png"883      },884      "last_poster": {885        "id": 60628,886        "username": "Mhtsf",887        "name": "",888        "avatar_template": "/letter_avatar_proxy/v4/letter/m/5f8ce5/{size}.png"889      }890    },891    "bookmarks": []892  },893  {894    "post_stream": {895      "posts": [896        {897          "id": 372698,898          "name": "Rahul Xie",899          "username": "Rahul_Xie",900          "avatar_template": "/user_avatar/discuss.pytorch.org/rahul_xie/{size}/46860_2.png",901          "created_at": "2022-10-31T13:58:51.975Z",902          "cooked": "<p>I want to change the gradient (STE) of the quantized model so that it supports back propagation, but it fails. Can someone tell me how to use the register_backward_hook () function or other methods to realize this function in the quantized model?</p>\n<pre><code class=\"lang-auto\">class MyNet(nn.Module):\n    def __init__(self):\n        super(MyNet, self).__init__()\n        self.f1 = nn.Linear(4, 1, bias=True)\n        self.f2 = MyMean()\n        self.quant = torch.quantization.QuantStub()\n        self.dequant = torch.quantization.DeQuantStub()\n        self.weight_init()\n        self.quant.register_backward_hook(self.my_hook)\n\n    def forward(self, input):\n        self.input = input\n        output = self.quant(input)\n        output = self.f1(output)  # 先进行运算1,后进行运算2\n        output = self.quant(self.f2(self.dequant(output)))\n        output = self.dequant(output)\n        return output\n\n    def weight_init(self):\n        self.f1.weight.data.fill_(8.0)  # 这里设置Linear的权重为8\n        self.f1.bias.data.fill_(2.0)  # 这里设置Linear的bias为2\n\n    def my_hook(self, module, grad_input, grad_output):\n        print('doing my_hook')\n        print('original grad:', grad_input)\n        print('original outgrad:', grad_output)\n        # grad_input = grad_input[0]*self.input   \n        # grad_input = tuple([grad_input])    \n        # print('now grad:', grad_input)\n        return grad_output\n</code></pre>",903          "post_number": 1,904          "post_type": 1,905          "posts_count": 8,906          "updated_at": "2022-10-31T13:58:51.975Z",907          "reply_count": 0,908          "reply_to_post_number": null,909          "quote_count": 0,910          "incoming_link_count": 154,911          "reads": 11,912          "readers_count": 10,913          "score": 762.2,914          "yours": false,915          "topic_id": 164820,916          "topic_slug": "register-backward-hook-in-quantized-model",917          "display_username": "Rahul Xie",918          "primary_group_name": null,919          "flair_name": null,920          "flair_url": null,921          "flair_bg_color": null,922          "flair_color": null,923          "flair_group_id": null,924          "badges_granted": [],925          "version": 1,926          "can_edit": false,927          "can_delete": false,928          "can_recover": false,929          "can_see_hidden_post": false,930          "can_wiki": false,931          "read": true,932          "user_title": null,933          "bookmarked": false,934          "actions_summary": [],935          "moderator": false,936          "admin": false,937          "staff": false,938          "user_id": 56419,939          "hidden": false,940          "trust_level": 1,941          "deleted_at": null,942          "user_deleted": false,943          "edit_reason": null,944          "can_view_edit_history": true,945          "wiki": false,946          "post_url": "/t/register-backward-hook-in-quantized-model/164820/1",947          "can_accept_answer": false,948          "can_unaccept_answer": false,949          "accepted_answer": false,950          "topic_accepted_answer": true,951          "can_vote": false952        },953        {954          "id": 372718,955          "name": "Hd Charles",956          "username": "HDCharles",957          "avatar_template": "/user_avatar/discuss.pytorch.org/hdcharles/{size}/38408_2.png",958          "created_at": "2022-10-31T15:49:13.936Z",959          "cooked": "<p>firstly, unrelated to your question, the model above isn’t going to work well for quantization. You have self.quant used at multiple points in the forward, which means tha the quantization flow will only be able to assign a single set of quantization parameters that will need to be used in 2 places, drastically lowering accuracy.</p>\n<p>as for your question, the issue is that there are no weight tensors in quantized modules. Those tensors get packed into a special format that the quantized kernel can utilize more effectively, so there’s nothing to do backprop on.</p>\n<p>Generally the way something like this is done is by using fake quants i.e. modules that simulate quantized numerics with fp32 dtypes. Once training/whatever is complete, the model would then be converted to the quantized model.</p>\n<p>see <a href=\"https://pytorch.org/docs/stable/quantization.html#quantization-aware-training-for-static-quantization\" class=\"inline-onebox\" rel=\"noopener nofollow ugc\">Quantization — PyTorch 1.13 documentation</a> for more info</p>",960          "post_number": 2,961          "post_type": 1,962          "posts_count": 8,963          "updated_at": "2022-10-31T15:50:02.092Z",964          "reply_count": 1,965          "reply_to_post_number": null,966          "quote_count": 0,967          "incoming_link_count": 5,968          "reads": 10,969          "readers_count": 9,970          "score": 32.0,971          "yours": false,972          "topic_id": 164820,973          "topic_slug": "register-backward-hook-in-quantized-model",974          "display_username": "Hd Charles",975          "primary_group_name": null,976          "flair_name": null,977          "flair_url": null,978          "flair_bg_color": null,979          "flair_color": null,980          "flair_group_id": null,981          "badges_granted": [],982          "version": 1,983          "can_edit": false,984          "can_delete": false,985          "can_recover": false,986          "can_see_hidden_post": false,987          "can_wiki": false,988          "link_counts": [989            {990              "url": "https://pytorch.org/docs/stable/quantization.html#quantization-aware-training-for-static-quantization",991              "internal": false,992              "reflection": false,993              "title": "Quantization — PyTorch 1.13 documentation",994              "clicks": 9995            },996            {997              "url": "https://discuss.pytorch.org/t/how-does-gradient-calculation-in-quantization-aware-training-straight-through-estimatior/197771",998              "internal": true,999              "reflection": true,1000              "title": "How does gradient calculation in quantization-aware training? Straight through estimatior?",1001              "clicks": 01002            }1003          ],1004          "read": true,1005          "user_title": null,1006          "bookmarked": false,1007          "actions_summary": [],1008          "moderator": false,1009          "admin": false,1010          "staff": false,1011          "user_id": 45475,1012          "hidden": false,1013          "trust_level": 2,1014          "deleted_at": null,1015          "user_deleted": false,1016          "edit_reason": null,1017          "can_view_edit_history": true,1018          "wiki": false,1019          "post_url": "/t/register-backward-hook-in-quantized-model/164820/2",1020          "can_accept_answer": false,1021          "can_unaccept_answer": false,1022          "accepted_answer": false,1023          "topic_accepted_answer": true1024        },1025        {1026          "id": 372795,1027          "name": "Rahul Xie",1028          "username": "Rahul_Xie",1029          "avatar_template": "/user_avatar/discuss.pytorch.org/rahul_xie/{size}/46860_2.png",1030          "created_at": "2022-11-01T03:03:02.130Z",1031          "cooked": "<p>Thank you for your reply! However, My requirement is to make the quantified model support back propagation. Therefore, the fake quants will not work. How can I get the weight tensors in quantized modules?</p>",1032          "post_number": 3,1033          "post_type": 1,1034          "posts_count": 8,1035          "updated_at": "2022-11-01T03:03:02.130Z",1036          "reply_count": 1,1037          "reply_to_post_number": 2,1038          "quote_count": 0,1039          "incoming_link_count": 1,1040          "reads": 7,1041          "readers_count": 6,1042          "score": 11.4,1043          "yours": false,1044          "topic_id": 164820,1045          "topic_slug": "register-backward-hook-in-quantized-model",1046          "display_username": "Rahul Xie",1047          "primary_group_name": null,1048          "flair_name": null,1049          "flair_url": null,1050          "flair_bg_color": null,1051          "flair_color": null,1052          "flair_group_id": null,1053          "badges_granted": [],1054          "version": 1,1055          "can_edit": false,1056          "can_delete": false,1057          "can_recover": false,1058          "can_see_hidden_post": false,1059          "can_wiki": false,1060          "read": true,1061          "user_title": null,1062          "reply_to_user": {1063            "id": 45475,1064            "username": "HDCharles",1065            "name": "Hd Charles",1066            "avatar_template": "/user_avatar/discuss.pytorch.org/hdcharles/{size}/38408_2.png"1067          },1068          "bookmarked": false,1069          "actions_summary": [],1070          "moderator": false,1071          "admin": false,1072          "staff": false,1073          "user_id": 56419,1074          "hidden": false,1075          "trust_level": 1,1076          "deleted_at": null,1077          "user_deleted": false,1078          "edit_reason": null,1079          "can_view_edit_history": true,1080          "wiki": false,1081          "post_url": "/t/register-backward-hook-in-quantized-model/164820/3",1082          "can_accept_answer": false,1083          "can_unaccept_answer": false,1084          "accepted_answer": false,1085          "topic_accepted_answer": true1086        },1087        {1088          "id": 372832,1089          "name": "Hd Charles",1090          "username": "HDCharles",1091          "avatar_template": "/user_avatar/discuss.pytorch.org/hdcharles/{size}/38408_2.png",1092          "created_at": "2022-11-01T03:53:11.000Z",1093          "cooked": "<p>Generally module._weight() but depends on the module</p>",1094          "post_number": 4,1095          "post_type": 1,1096          "posts_count": 8,1097          "updated_at": "2022-11-01T04:00:08.473Z",1098          "reply_count": 1,1099          "reply_to_post_number": 3,1100          "quote_count": 0,1101          "incoming_link_count": 1,1102          "reads": 7,1103          "readers_count": 6,1104          "score": 11.4,1105          "yours": false,1106          "topic_id": 164820,1107          "topic_slug": "register-backward-hook-in-quantized-model",1108          "display_username": "Hd Charles",1109          "primary_group_name": null,1110          "flair_name": null,1111          "flair_url": null,1112          "flair_bg_color": null,1113          "flair_color": null,1114          "flair_group_id": null,1115          "badges_granted": [],1116          "version": 1,1117          "can_edit": false,1118          "can_delete": false,1119          "can_recover": false,1120          "can_see_hidden_post": false,1121          "can_wiki": false,1122          "read": true,1123          "user_title": null,1124          "reply_to_user": {1125            "id": 56419,1126            "username": "Rahul_Xie",1127            "name": "Rahul Xie",1128            "avatar_template": "/user_avatar/discuss.pytorch.org/rahul_xie/{size}/46860_2.png"1129          },1130          "bookmarked": false,1131          "actions_summary": [],1132          "moderator": false,1133          "admin": false,1134          "staff": false,1135          "user_id": 45475,1136          "hidden": false,1137          "trust_level": 2,1138          "deleted_at": null,1139          "user_deleted": false,1140          "edit_reason": null,1141          "can_view_edit_history": true,1142          "wiki": false,1143          "via_email": true,1144          "post_url": "/t/register-backward-hook-in-quantized-model/164820/4",1145          "can_accept_answer": false,1146          "can_unaccept_answer": false,1147          "accepted_answer": false,1148          "topic_accepted_answer": true1149        },1150        {1151          "id": 372846,1152          "name": "Rahul Xie",1153          "username": "Rahul_Xie",1154          "avatar_template": "/user_avatar/discuss.pytorch.org/rahul_xie/{size}/46860_2.png",1155          "created_at": "2022-11-01T07:23:40.170Z",1156          "cooked": "<p>Is there any solution to support backpropagation in the model has been quantized?</p>",1157          "post_number": 5,1158          "post_type": 1,1159          "posts_count": 8,1160          "updated_at": "2022-11-01T07:23:40.170Z",1161          "reply_count": 1,1162          "reply_to_post_number": 4,1163          "quote_count": 0,1164          "incoming_link_count": 0,1165          "reads": 7,1166          "readers_count": 6,1167          "score": 6.4,1168          "yours": false,1169          "topic_id": 164820,1170          "topic_slug": "register-backward-hook-in-quantized-model",1171          "display_username": "Rahul Xie",1172          "primary_group_name": null,1173          "flair_name": null,1174          "flair_url": null,1175          "flair_bg_color": null,1176          "flair_color": null,1177          "flair_group_id": null,1178          "badges_granted": [],1179          "version": 1,1180          "can_edit": false,1181          "can_delete": false,1182          "can_recover": false,1183          "can_see_hidden_post": false,1184          "can_wiki": false,1185          "read": true,1186          "user_title": null,1187          "reply_to_user": {1188            "id": 45475,1189            "username": "HDCharles",1190            "name": "Hd Charles",1191            "avatar_template": "/user_avatar/discuss.pytorch.org/hdcharles/{size}/38408_2.png"1192          },1193          "bookmarked": false,1194          "actions_summary": [],1195          "moderator": false,1196          "admin": false,1197          "staff": false,1198          "user_id": 56419,1199          "hidden": false,1200          "trust_level": 1,

Showing the first 1,200 of 57458 lines. Download the file for the rest.