Anurag1734/cuda-error-resolution-analysis
07
1[2 {3 "post_stream": {4 "posts": [5 {6 "id": 111285,7 "name": "윤 허",8 "username": "dedf21972b190932c756",9 "avatar_template": "/user_avatar/discuss.pytorch.org/dedf21972b190932c756/{size}/12023_2.png",10 "created_at": "2019-05-14T05:57:37.782Z",11 "cooked": "<p>i’m making sentiment analysis in Korean version.<br>\nBut I got this error, “TypeError: ‘<’ not supported between instances of ‘Example’ and ‘Example’”</p>\n<h2>This is my abstract code :</h2>\n<p>import torch<br>\nfrom torchtext import data<br>\nfrom torchtext import datasets<br>\nfrom soynlp.tokenizer import MaxScoreTokenizer<br>\nSEED = 1234</p>\n<p>torch.manual_seed(SEED)<br>\ntorch.backends.cudnn.deterministic = True</p>\n<p><span class=\"hashtag\">#When</span> tokenizing, some text will be null<br>\nTEXT = data.Field(tokenize = tokenizer, preprocessing = generate_bigrams, stop_words = stop_words)<br>\nLABEL = data.LabelField(dtype = torch.float)</p>\n<p>from torchtext.data import TabularDataset<br>\nfields = [(“text”, TEXT),(“label”, LABEL)]</p>\n<p>train_data, test_data = data.TabularDataset.splits(<br>\npath = ‘’,<br>\ntrain = ‘train.csv’,<br>\ntest = ‘train.csv’,<br>\nformat = ‘csv’,<br>\nfields = fields,<br>\nskip_header = True<br>\n)</p>\n<p>import torchtext<br>\nvec = torchtext.vocab.Vectors(‘wiki.ko.vec’, cache=’./Downloads/’)<br>\nTEXT.build_vocab(train_data,<br>\nmax_size = MAX_VOCAB_SIZE,<br>\nvectors = vec,<br>\nunk_init = torch.Tensor.normal_)<br>\nLABEL.build_vocab(train_data)</p>\n<p>BATCH_SIZE = 32</p>\n<p>device = torch.device(‘cuda’ if torch.cuda.is_available() else ‘cpu’)</p>\n<p>train_iterator, test_iterator = data.BucketIterator.splits(<br>\n(train_data, test_data),<br>\nbatch_size = BATCH_SIZE,<br>\ndevice = device)<br>\nprint(‘Train:’)<br>\nfor batch in train_iterator:<br>\nprint(batch)</p>\n<h2>print(‘Test:’)<br>\nfor batch in test_iterator:<br>\nprint(batch)</h2>\n<p>And then, I got the this error</p>\n<h2>Test:</h2>\n<p>TypeError Traceback (most recent call last)<br>\n in <br>\n12<br>\n13 print(‘Test:’)<br>\n—> 14 for batch in test_iterator:<br>\n15 print(batch)</p>\n<p>/anaconda3/lib/python3.7/site-packages/torchtext/data/iterator.py in <strong>iter</strong>(self)<br>\n140 def <strong>iter</strong>(self):<br>\n141 while True:<br>\n–> 142 self.init_epoch()<br>\n143 for idx, minibatch in enumerate(self.batches):<br>\n144 # fast-forward if loaded from state</p>\n<p>/anaconda3/lib/python3.7/site-packages/torchtext/data/iterator.py in init_epoch(self)<br>\n116 self._random_state_this_epoch = self.random_shuffler.random_state<br>\n117<br>\n–> 118 self.create_batches()<br>\n119<br>\n120 if self._restored_from_state:</p>\n<p>/anaconda3/lib/python3.7/site-packages/torchtext/data/iterator.py in create_batches(self)<br>\n240 def create_batches(self):<br>\n241 if self.sort:<br>\n–> 242 self.batches = batch(self.data(), self.batch_size,<br>\n243 self.batch_size_fn)<br>\n244 else:</p>\n<p>/anaconda3/lib/python3.7/site-packages/torchtext/data/iterator.py in data(self)<br>\n101 “”“Return the examples in the dataset in order, sorted, or shuffled.”\"\"<br>\n102 if self.sort:<br>\n–> 103 xs = sorted(self.dataset, key=self.sort_key)<br>\n104 elif self.shuffle:<br>\n105 xs = [self.dataset[i] for i in self.random_shuffler(range(len(self.dataset)))]</p>\n<p>TypeError: ‘<’ not supported between instances of ‘Example’ and ‘Example’<br>\nI don’t know why the error happend, even I set the same file in train and test for finding the reasons!!</p>\n<p>Thank you in advance.</p>",12 "post_number": 1,13 "post_type": 1,14 "posts_count": 2,15 "updated_at": "2019-05-14T05:57:37.782Z",16 "reply_count": 0,17 "reply_to_post_number": null,18 "quote_count": 0,19 "incoming_link_count": 3453,20 "reads": 59,21 "readers_count": 58,22 "score": 17251.8,23 "yours": false,24 "topic_id": 45182,25 "topic_slug": "typeerror-not-supported-between-instances-of-example-and-example",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 "read": true,41 "user_title": null,42 "bookmarked": false,43 "actions_summary": [],44 "moderator": false,45 "admin": false,46 "staff": false,47 "user_id": 18558,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/typeerror-not-supported-between-instances-of-example-and-example/45182/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": 111289,64 "name": "Alex Veuthey",65 "username": "alex.veuthey",66 "avatar_template": "/user_avatar/discuss.pytorch.org/alex.veuthey/{size}/12176_2.png",67 "created_at": "2019-05-14T06:26:40.151Z",68 "cooked": "<p>This happens because the dataset iterator from <code>torchtext</code> tries to sort the dataset, which implies comparing two elements.</p>\n<p>Apparently this is a known “feature” and you have to provide a sorting function to the constructor of the <code>BucketIterator</code>, as seen in <a href=\"https://github.com/pytorch/text/issues/474\" rel=\"nofollow noopener\">this issue</a>.</p>",69 "post_number": 2,70 "post_type": 1,71 "posts_count": 2,72 "updated_at": "2019-05-14T06:26:40.151Z",73 "reply_count": 0,74 "reply_to_post_number": null,75 "quote_count": 0,76 "incoming_link_count": 56,77 "reads": 50,78 "readers_count": 49,79 "score": 335.0,80 "yours": false,81 "topic_id": 45182,82 "topic_slug": "typeerror-not-supported-between-instances-of-example-and-example",83 "display_username": "Alex Veuthey",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/text/issues/474",100 "internal": false,101 "reflection": false,102 "title": "TypeError: '<' not supported between instances of 'Example' and 'Example' · Issue #474 · pytorch/text · GitHub",103 "clicks": 752104 }105 ],106 "read": true,107 "user_title": null,108 "bookmarked": false,109 "actions_summary": [110 {111 "id": 2,112 "count": 1113 }114 ],115 "moderator": false,116 "admin": false,117 "staff": false,118 "user_id": 13993,119 "hidden": false,120 "trust_level": 2,121 "deleted_at": null,122 "user_deleted": false,123 "edit_reason": null,124 "can_view_edit_history": true,125 "wiki": false,126 "post_url": "/t/typeerror-not-supported-between-instances-of-example-and-example/45182/2",127 "can_accept_answer": false,128 "can_unaccept_answer": false,129 "accepted_answer": false,130 "topic_accepted_answer": null131 }132 ],133 "stream": [134 111285,135 111289136 ]137 },138 "timeline_lookup": [139 [140 1,141 2357142 ]143 ],144 "suggested_topics": [145 {146 "fancy_title": "Join us for the LLM Hackathon in Ecology in Bielefeld, Germany, or Online!",147 "id": 213759,148 "title": "Join us for the LLM Hackathon in Ecology in Bielefeld, Germany, or Online!",149 "slug": "join-us-for-the-llm-hackathon-in-ecology-in-bielefeld-germany-or-online",150 "posts_count": 1,151 "reply_count": 0,152 "highest_post_number": 1,153 "image_url": null,154 "created_at": "2024-12-03T18:31:08.536Z",155 "last_posted_at": "2024-12-03T18:31:08.584Z",156 "bumped": true,157 "bumped_at": "2024-12-03T18:31:08.584Z",158 "archetype": "regular",159 "unseen": false,160 "pinned": false,161 "unpinned": null,162 "visible": true,163 "closed": false,164 "archived": false,165 "bookmarked": null,166 "liked": null,167 "tags_descriptions": {},168 "like_count": 0,169 "views": 22,170 "category_id": 1,171 "featured_link": null,172 "has_accepted_answer": false,173 "posters": [174 {175 "extras": "latest single",176 "description": "Original Poster, Most Recent Poster",177 "user": {178 "id": 81280,179 "username": "Jennifer_DSouza",180 "name": "",181 "avatar_template": "/user_avatar/discuss.pytorch.org/jennifer_dsouza/{size}/73214_2.png",182 "trust_level": 0183 }184 }185 ]186 },187 {188 "fancy_title": "Which parameters torch.nn forward() method takes in? Is PyTorch forward() equivalent to standard forward pass?",189 "id": 212856,190 "title": "Which parameters torch.nn forward() method takes in? Is PyTorch forward() equivalent to standard forward pass?",191 "slug": "which-parameters-torch-nn-forward-method-takes-in-is-pytorch-forward-equivalent-to-standard-forward-pass",192 "posts_count": 4,193 "reply_count": 2,194 "highest_post_number": 4,195 "image_url": null,196 "created_at": "2024-11-12T10:26:26.036Z",197 "last_posted_at": "2024-11-12T13:33:11.372Z",198 "bumped": true,199 "bumped_at": "2024-11-12T13:33:11.372Z",200 "archetype": "regular",201 "unseen": false,202 "pinned": false,203 "unpinned": null,204 "visible": true,205 "closed": false,206 "archived": false,207 "bookmarked": null,208 "liked": null,209 "tags_descriptions": {},210 "like_count": 0,211 "views": 86,212 "category_id": 1,213 "featured_link": null,214 "has_accepted_answer": false,215 "posters": [216 {217 "extras": null,218 "description": "Original Poster",219 "user": {220 "id": 80828,221 "username": "R.Mukhamadiarov",222 "name": "Ruslan Mukhamadiarov",223 "avatar_template": "/user_avatar/discuss.pytorch.org/r.mukhamadiarov/{size}/73639_2.png",224 "trust_level": 0225 }226 },227 {228 "extras": "latest",229 "description": "Most Recent Poster",230 "user": {231 "id": 72430,232 "username": "Eduardo_Lawson",233 "name": "Eduardo Lawson da Silva",234 "avatar_template": "/user_avatar/discuss.pytorch.org/eduardo_lawson/{size}/66899_2.png",235 "trust_level": 2236 }237 }238 ]239 },240 {241 "fancy_title": "How can I combine my custom conv2D in CUDA C and autograd of pytorch",242 "id": 216106,243 "title": "How can I combine my custom conv2D in CUDA C and autograd of pytorch",244 "slug": "how-can-i-combine-my-custom-conv2d-in-cuda-c-and-autograd-of-pytorch",245 "posts_count": 1,246 "reply_count": 0,247 "highest_post_number": 1,248 "image_url": null,249 "created_at": "2025-01-31T22:01:03.923Z",250 "last_posted_at": "2025-01-31T22:01:03.968Z",251 "bumped": true,252 "bumped_at": "2025-01-31T22:01:03.968Z",253 "archetype": "regular",254 "unseen": false,255 "pinned": false,256 "unpinned": null,257 "visible": true,258 "closed": false,259 "archived": false,260 "bookmarked": null,261 "liked": null,262 "tags_descriptions": {},263 "like_count": 0,264 "views": 32,265 "category_id": 1,266 "featured_link": null,267 "has_accepted_answer": false,268 "posters": [269 {270 "extras": "latest single",271 "description": "Original Poster, Most Recent Poster",272 "user": {273 "id": 66124,274 "username": "Aakira",275 "name": "Aakira",276 "avatar_template": "/user_avatar/discuss.pytorch.org/aakira/{size}/58984_2.png",277 "trust_level": 1278 }279 }280 ]281 },282 {283 "fancy_title": "How will torch.cuda.Event `elapsed_time` method behave without explicit torch.cuda.synchronize?",284 "id": 216163,285 "title": "How will torch.cuda.Event `elapsed_time` method behave without explicit torch.cuda.synchronize?",286 "slug": "how-will-torch-cuda-event-elapsed-time-method-behave-without-explicit-torch-cuda-synchronize",287 "posts_count": 4,288 "reply_count": 2,289 "highest_post_number": 4,290 "image_url": null,291 "created_at": "2025-02-03T05:55:21.578Z",292 "last_posted_at": "2025-05-03T00:10:15.451Z",293 "bumped": true,294 "bumped_at": "2025-05-03T00:10:15.451Z",295 "archetype": "regular",296 "unseen": false,297 "pinned": false,298 "unpinned": null,299 "visible": true,300 "closed": false,301 "archived": false,302 "bookmarked": null,303 "liked": null,304 "tags_descriptions": {},305 "like_count": 0,306 "views": 170,307 "category_id": 1,308 "featured_link": null,309 "has_accepted_answer": false,310 "posters": [311 {312 "extras": "latest",313 "description": "Original Poster, Most Recent Poster",314 "user": {315 "id": 16086,316 "username": "justinliu",317 "name": "Justin Liu",318 "avatar_template": "/letter_avatar_proxy/v4/letter/j/f07891/{size}.png",319 "trust_level": 1320 }321 },322 {323 "extras": null,324 "description": "Frequent Poster",325 "user": {326 "id": 3534,327 "username": "ptrblck",328 "name": "",329 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",330 "admin": true,331 "moderator": true,332 "trust_level": 2333 }334 }335 ]336 },337 {338 "fancy_title": "Need Language Model Advice",339 "id": 216445,340 "title": "Need Language Model Advice",341 "slug": "need-language-model-advice",342 "posts_count": 1,343 "reply_count": 0,344 "highest_post_number": 1,345 "image_url": null,346 "created_at": "2025-02-10T03:34:02.769Z",347 "last_posted_at": "2025-02-10T03:34:02.810Z",348 "bumped": true,349 "bumped_at": "2025-02-10T12:44:59.110Z",350 "archetype": "regular",351 "unseen": false,352 "pinned": false,353 "unpinned": null,354 "visible": true,355 "closed": false,356 "archived": false,357 "bookmarked": null,358 "liked": null,359 "tags_descriptions": {},360 "like_count": 0,361 "views": 20,362 "category_id": 1,363 "featured_link": null,364 "has_accepted_answer": false,365 "posters": [366 {367 "extras": "latest single",368 "description": "Original Poster, Most Recent Poster",369 "user": {370 "id": 73472,371 "username": "TheVictor_777",372 "name": "",373 "avatar_template": "/letter_avatar_proxy/v4/letter/t/5daacb/{size}.png",374 "trust_level": 1375 }376 }377 ]378 }379 ],380 "tags_descriptions": {},381 "fancy_title": "TypeError: ‘<’ not supported between instances of ‘Example’ and ‘Example’",382 "id": 45182,383 "title": "TypeError: '<' not supported between instances of 'Example' and 'Example'",384 "posts_count": 2,385 "created_at": "2019-05-14T05:57:37.728Z",386 "views": 4333,387 "reply_count": 0,388 "like_count": 1,389 "last_posted_at": "2019-05-14T06:26:40.151Z",390 "visible": true,391 "closed": false,392 "archived": false,393 "has_summary": false,394 "archetype": "regular",395 "slug": "typeerror-not-supported-between-instances-of-example-and-example",396 "category_id": 1,397 "word_count": 438,398 "deleted_at": null,399 "user_id": 18558,400 "featured_link": null,401 "pinned_globally": false,402 "pinned_at": null,403 "pinned_until": null,404 "image_url": null,405 "slow_mode_seconds": 0,406 "draft": null,407 "draft_key": "topic_45182",408 "draft_sequence": null,409 "unpinned": null,410 "pinned": false,411 "current_post_number": 1,412 "highest_post_number": 2,413 "deleted_by": null,414 "actions_summary": [415 {416 "id": 4,417 "count": 0,418 "hidden": false,419 "can_act": false420 },421 {422 "id": 8,423 "count": 0,424 "hidden": false,425 "can_act": false426 },427 {428 "id": 10,429 "count": 0,430 "hidden": false,431 "can_act": false432 },433 {434 "id": 7,435 "count": 0,436 "hidden": false,437 "can_act": false438 }439 ],440 "chunk_size": 20,441 "bookmarked": false,442 "topic_timer": null,443 "message_bus_last_id": 0,444 "participant_count": 2,445 "show_read_indicator": false,446 "thumbnails": null,447 "slow_mode_enabled_until": null,448 "can_vote": false,449 "vote_count": 0,450 "user_voted": false,451 "discourse_zendesk_plugin_zendesk_id": null,452 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",453 "details": {454 "can_edit": false,455 "notification_level": 1,456 "participants": [457 {458 "id": 13993,459 "username": "alex.veuthey",460 "name": "Alex Veuthey",461 "avatar_template": "/user_avatar/discuss.pytorch.org/alex.veuthey/{size}/12176_2.png",462 "post_count": 1,463 "primary_group_name": null,464 "flair_name": null,465 "flair_url": null,466 "flair_color": null,467 "flair_bg_color": null,468 "flair_group_id": null,469 "trust_level": 2470 },471 {472 "id": 18558,473 "username": "dedf21972b190932c756",474 "name": "윤 허",475 "avatar_template": "/user_avatar/discuss.pytorch.org/dedf21972b190932c756/{size}/12023_2.png",476 "post_count": 1,477 "primary_group_name": null,478 "flair_name": null,479 "flair_url": null,480 "flair_color": null,481 "flair_bg_color": null,482 "flair_group_id": null,483 "trust_level": 1484 }485 ],486 "created_by": {487 "id": 18558,488 "username": "dedf21972b190932c756",489 "name": "윤 허",490 "avatar_template": "/user_avatar/discuss.pytorch.org/dedf21972b190932c756/{size}/12023_2.png"491 },492 "last_poster": {493 "id": 13993,494 "username": "alex.veuthey",495 "name": "Alex Veuthey",496 "avatar_template": "/user_avatar/discuss.pytorch.org/alex.veuthey/{size}/12176_2.png"497 },498 "links": [499 {500 "url": "https://github.com/pytorch/text/issues/474",501 "title": "TypeError: '<' not supported between instances of 'Example' and 'Example' · Issue #474 · pytorch/text · GitHub",502 "internal": false,503 "attachment": false,504 "reflection": false,505 "clicks": 752,506 "user_id": 13993,507 "domain": "github.com",508 "root_domain": "github.com"509 }510 ]511 },512 "bookmarks": []513 },514 {515 "post_stream": {516 "posts": [517 {518 "id": 110892,519 "name": "윤 허",520 "username": "dedf21972b190932c756",521 "avatar_template": "/user_avatar/discuss.pytorch.org/dedf21972b190932c756/{size}/12023_2.png",522 "created_at": "2019-05-11T13:11:37.117Z",523 "cooked": "<p>Hi, I am new to deep learning.<br>\nI have tired to make sentiment analysis, but I have some problems.<br>\nUsually, many people code like this:<br>\nTEXT = data.Field(tokenize = ‘spacy’)<br>\nLABEL = data.LabelField(dtype = torch.float)</p>\n<p>But, I want to make Korean version.<br>\nI can’t use spacy, because spacy doesn’t offer Korean.<br>\nThere is a my question.<br>\nHow to make custom tokenize class?<br>\nI don’t know what type to return, list? str?<br>\nWhat kind of return types does tokenize want in data.Field?<br>\nPlease answer.<br>\nThank you !</p>",524 "post_number": 1,525 "post_type": 1,526 "posts_count": 3,527 "updated_at": "2019-05-11T13:11:37.117Z",528 "reply_count": 0,529 "reply_to_post_number": null,530 "quote_count": 0,531 "incoming_link_count": 335,532 "reads": 18,533 "readers_count": 17,534 "score": 1678.6,535 "yours": false,536 "topic_id": 44986,537 "topic_slug": "what-is-tokenizes-type-in-field",538 "display_username": "윤 허",539 "primary_group_name": null,540 "flair_name": null,541 "flair_url": null,542 "flair_bg_color": null,543 "flair_color": null,544 "flair_group_id": null,545 "badges_granted": [],546 "version": 1,547 "can_edit": false,548 "can_delete": false,549 "can_recover": false,550 "can_see_hidden_post": false,551 "can_wiki": false,552 "read": true,553 "user_title": null,554 "bookmarked": false,555 "actions_summary": [],556 "moderator": false,557 "admin": false,558 "staff": false,559 "user_id": 18558,560 "hidden": false,561 "trust_level": 1,562 "deleted_at": null,563 "user_deleted": false,564 "edit_reason": null,565 "can_view_edit_history": true,566 "wiki": false,567 "post_url": "/t/what-is-tokenizes-type-in-field/44986/1",568 "can_accept_answer": false,569 "can_unaccept_answer": false,570 "accepted_answer": false,571 "topic_accepted_answer": null,572 "can_vote": false573 },574 {575 "id": 111028,576 "name": "James Callinicos",577 "username": "JamesTrick",578 "avatar_template": "/user_avatar/discuss.pytorch.org/jamestrick/{size}/10956_2.png",579 "created_at": "2019-05-12T22:18:50.634Z",580 "cooked": "<p>Hiya!</p>\n<p>I’m not familiar with the Korean language, so this answer will be a bit general.</p>\n<p>With torchtext, you’re able to pass your own tokenizer to it. In a simple but extensible example check this out.</p>\n<pre><code class=\"lang-auto\">def tokenizer(text):\n \"\"\"\n Function to tokenize given string of text.\n # Arguments:\n text: (str) String to be tokenized.\n # Returns:\n List of tokens.\n \"\"\"\n return str.split() # This returns the list of tokens.\n</code></pre>\n<p>You can then pass it into torchtext using the following. <code>TEXT = data.Field(tokenize=tokenizer)</code></p>\n<p>To extend it to Korean, you’ll need to find or develop a tokenizer function that works for Korean <img src=\"https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9\" title=\":slight_smile:\" class=\"emoji\" alt=\":slight_smile:\"></p>\n<p>Hopefully that helps!</p>",581 "post_number": 2,582 "post_type": 1,583 "posts_count": 3,584 "updated_at": "2019-05-12T22:18:50.634Z",585 "reply_count": 1,586 "reply_to_post_number": null,587 "quote_count": 0,588 "incoming_link_count": 7,589 "reads": 16,590 "readers_count": 15,591 "score": 43.2,592 "yours": false,593 "topic_id": 44986,594 "topic_slug": "what-is-tokenizes-type-in-field",595 "display_username": "James Callinicos",596 "primary_group_name": null,597 "flair_name": null,598 "flair_url": null,599 "flair_bg_color": null,600 "flair_color": null,601 "flair_group_id": null,602 "badges_granted": [],603 "version": 1,604 "can_edit": false,605 "can_delete": false,606 "can_recover": false,607 "can_see_hidden_post": false,608 "can_wiki": false,609 "read": true,610 "user_title": null,611 "bookmarked": false,612 "actions_summary": [],613 "moderator": false,614 "admin": false,615 "staff": false,616 "user_id": 17564,617 "hidden": false,618 "trust_level": 2,619 "deleted_at": null,620 "user_deleted": false,621 "edit_reason": null,622 "can_view_edit_history": true,623 "wiki": false,624 "post_url": "/t/what-is-tokenizes-type-in-field/44986/2",625 "can_accept_answer": false,626 "can_unaccept_answer": false,627 "accepted_answer": false,628 "topic_accepted_answer": null629 },630 {631 "id": 111281,632 "name": "윤 허",633 "username": "dedf21972b190932c756",634 "avatar_template": "/user_avatar/discuss.pytorch.org/dedf21972b190932c756/{size}/12023_2.png",635 "created_at": "2019-05-14T04:55:55.496Z",636 "cooked": "<p>Hi ~<br>\nThank you for comments!!!<br>\nI found the Korean tokenizer and applied it ^^<br>\nBut, I am also curious about how to treat when text is NULL.<br>\nI’d like to remove whole train data.<br>\nType is torchtext.data.example.Example.<br>\nDo you know about that?</p>",637 "post_number": 3,638 "post_type": 1,639 "posts_count": 3,640 "updated_at": "2019-05-14T04:55:55.496Z",641 "reply_count": 0,642 "reply_to_post_number": 2,643 "quote_count": 0,644 "incoming_link_count": 3,645 "reads": 16,646 "readers_count": 15,647 "score": 18.2,648 "yours": false,649 "topic_id": 44986,650 "topic_slug": "what-is-tokenizes-type-in-field",651 "display_username": "윤 허",652 "primary_group_name": null,653 "flair_name": null,654 "flair_url": null,655 "flair_bg_color": null,656 "flair_color": null,657 "flair_group_id": null,658 "badges_granted": [],659 "version": 1,660 "can_edit": false,661 "can_delete": false,662 "can_recover": false,663 "can_see_hidden_post": false,664 "can_wiki": false,665 "read": true,666 "user_title": null,667 "reply_to_user": {668 "id": 17564,669 "username": "JamesTrick",670 "name": "James Callinicos",671 "avatar_template": "/user_avatar/discuss.pytorch.org/jamestrick/{size}/10956_2.png"672 },673 "bookmarked": false,674 "actions_summary": [],675 "moderator": false,676 "admin": false,677 "staff": false,678 "user_id": 18558,679 "hidden": false,680 "trust_level": 1,681 "deleted_at": null,682 "user_deleted": false,683 "edit_reason": null,684 "can_view_edit_history": true,685 "wiki": false,686 "post_url": "/t/what-is-tokenizes-type-in-field/44986/3",687 "can_accept_answer": false,688 "can_unaccept_answer": false,689 "accepted_answer": false,690 "topic_accepted_answer": null691 }692 ],693 "stream": [694 110892,695 111028,696 111281697 ]698 },699 "timeline_lookup": [700 [701 1,702 2359703 ],704 [705 2,706 2358707 ],708 [709 3,710 2357711 ]712 ],713 "suggested_topics": [714 {715 "fancy_title": "Slow attention when using kvCache",716 "id": 216970,717 "title": "Slow attention when using kvCache",718 "slug": "slow-attention-when-using-kvcache",719 "posts_count": 2,720 "reply_count": 0,721 "highest_post_number": 2,722 "image_url": "https://discuss.pytorch.org/uploads/default/optimized/3X/4/8/48b8b2fe5bbc5b043e270063d7b0fd56f6ac7909_2_1023x299.jpeg",723 "created_at": "2025-02-21T01:42:07.857Z",724 "last_posted_at": "2025-02-21T14:02:17.595Z",725 "bumped": true,726 "bumped_at": "2025-02-21T14:02:17.595Z",727 "archetype": "regular",728 "unseen": false,729 "pinned": false,730 "unpinned": null,731 "visible": true,732 "closed": false,733 "archived": false,734 "bookmarked": null,735 "liked": null,736 "tags_descriptions": {},737 "like_count": 0,738 "views": 77,739 "category_id": 8,740 "featured_link": null,741 "has_accepted_answer": false,742 "posters": [743 {744 "extras": null,745 "description": "Original Poster",746 "user": {747 "id": 82829,748 "username": "ywha0929",749 "name": "영우 하",750 "avatar_template": "/user_avatar/discuss.pytorch.org/ywha0929/{size}/75789_2.png",751 "trust_level": 1752 }753 },754 {755 "extras": "latest",756 "description": "Most Recent Poster",757 "user": {758 "id": 3534,759 "username": "ptrblck",760 "name": "",761 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",762 "admin": true,763 "moderator": true,764 "trust_level": 2765 }766 }767 ]768 },769 {770 "fancy_title": "Documents as parametric memory",771 "id": 215242,772 "title": "Documents as parametric memory",773 "slug": "documents-as-parametric-memory",774 "posts_count": 1,775 "reply_count": 0,776 "highest_post_number": 1,777 "image_url": null,778 "created_at": "2025-01-11T01:22:00.572Z",779 "last_posted_at": "2025-01-11T01:22:00.615Z",780 "bumped": true,781 "bumped_at": "2025-01-11T01:22:00.615Z",782 "archetype": "regular",783 "unseen": false,784 "pinned": false,785 "unpinned": null,786 "visible": true,787 "closed": false,788 "archived": false,789 "bookmarked": null,790 "liked": null,791 "tags_descriptions": {},792 "like_count": 0,793 "views": 103,794 "category_id": 8,795 "featured_link": null,796 "has_accepted_answer": false,797 "posters": [798 {799 "extras": "latest single",800 "description": "Original Poster, Most Recent Poster",801 "user": {802 "id": 72190,803 "username": "Sai1",804 "name": "Sai",805 "avatar_template": "/user_avatar/discuss.pytorch.org/sai1/{size}/62072_2.png",806 "trust_level": 1807 }808 }809 ]810 },811 {812 "fancy_title": "Why my Traing accuracy remains constant",813 "id": 215399,814 "title": "Why my Traing accuracy remains constant",815 "slug": "why-my-traing-accuracy-remains-constant",816 "posts_count": 3,817 "reply_count": 0,818 "highest_post_number": 3,819 "image_url": null,820 "created_at": "2025-01-15T00:27:15.842Z",821 "last_posted_at": "2025-01-20T00:33:10.329Z",822 "bumped": true,823 "bumped_at": "2025-01-20T00:33:10.329Z",824 "archetype": "regular",825 "unseen": false,826 "pinned": false,827 "unpinned": null,828 "visible": true,829 "closed": false,830 "archived": false,831 "bookmarked": null,832 "liked": null,833 "tags_descriptions": {},834 "like_count": 0,835 "views": 176,836 "category_id": 8,837 "featured_link": null,838 "has_accepted_answer": false,839 "posters": [840 {841 "extras": null,842 "description": "Original Poster",843 "user": {844 "id": 82093,845 "username": "arsh_sharma",846 "name": "arsh sharma",847 "avatar_template": "/user_avatar/discuss.pytorch.org/arsh_sharma/{size}/75107_2.png",848 "trust_level": 0849 }850 },851 {852 "extras": null,853 "description": "Frequent Poster",854 "user": {855 "id": 3534,856 "username": "ptrblck",857 "name": "",858 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",859 "admin": true,860 "moderator": true,861 "trust_level": 2862 }863 },864 {865 "extras": "latest",866 "description": "Most Recent Poster",867 "user": {868 "id": 1438,869 "username": "vdw",870 "name": "Chris",871 "avatar_template": "/user_avatar/discuss.pytorch.org/vdw/{size}/10074_2.png",872 "trust_level": 2873 }874 }875 ]876 },877 {878 "fancy_title": "What is the right way to structure `input` and `label` while fine-tuning decoder only model",879 "id": 215931,880 "title": "What is the right way to structure `input` and `label` while fine-tuning decoder only model",881 "slug": "what-is-the-right-way-to-structure-input-and-label-while-fine-tuning-decoder-only-model",882 "posts_count": 1,883 "reply_count": 0,884 "highest_post_number": 1,885 "image_url": null,886 "created_at": "2025-01-27T13:15:44.900Z",887 "last_posted_at": "2025-01-27T13:15:44.942Z",888 "bumped": true,889 "bumped_at": "2025-01-27T13:48:53.036Z",890 "archetype": "regular",891 "unseen": false,892 "pinned": false,893 "unpinned": null,894 "visible": true,895 "closed": false,896 "archived": false,897 "bookmarked": null,898 "liked": null,899 "tags_descriptions": {},900 "like_count": 0,901 "views": 31,902 "category_id": 8,903 "featured_link": null,904 "has_accepted_answer": false,905 "posters": [906 {907 "extras": "latest single",908 "description": "Original Poster, Most Recent Poster",909 "user": {910 "id": 77539,911 "username": "Seungjun_Lee",912 "name": "Seungjun Lee",913 "avatar_template": "/user_avatar/discuss.pytorch.org/seungjun_lee/{size}/71547_2.png",914 "trust_level": 1915 }916 }917 ]918 },919 {920 "fancy_title": "Pytorch OCR models for deploying to ESP32?",921 "id": 217755,922 "title": "Pytorch OCR models for deploying to ESP32?",923 "slug": "pytorch-ocr-models-for-deploying-to-esp32",924 "posts_count": 1,925 "reply_count": 0,926 "highest_post_number": 1,927 "image_url": null,928 "created_at": "2025-03-12T17:14:45.612Z",929 "last_posted_at": "2025-03-12T17:14:45.651Z",930 "bumped": true,931 "bumped_at": "2025-03-12T17:14:45.651Z",932 "archetype": "regular",933 "unseen": false,934 "pinned": false,935 "unpinned": null,936 "visible": true,937 "closed": false,938 "archived": false,939 "bookmarked": null,940 "liked": null,941 "tags_descriptions": {},942 "like_count": 0,943 "views": 126,944 "category_id": 8,945 "featured_link": null,946 "has_accepted_answer": false,947 "posters": [948 {949 "extras": "latest single",950 "description": "Original Poster, Most Recent Poster",951 "user": {952 "id": 83222,953 "username": "mavavilj",954 "name": "Matti",955 "avatar_template": "/user_avatar/discuss.pytorch.org/mavavilj/{size}/76119_2.png",956 "trust_level": 0957 }958 }959 ]960 }961 ],962 "tags_descriptions": {},963 "fancy_title": "What is tokenize’s type in Field",964 "id": 44986,965 "title": "What is tokenize's type in Field",966 "posts_count": 3,967 "created_at": "2019-05-11T13:11:37.068Z",968 "views": 1252,969 "reply_count": 1,970 "like_count": 0,971 "last_posted_at": "2019-05-14T04:55:55.496Z",972 "visible": true,973 "closed": false,974 "archived": false,975 "has_summary": false,976 "archetype": "regular",977 "slug": "what-is-tokenizes-type-in-field",978 "category_id": 8,979 "word_count": 241,980 "deleted_at": null,981 "user_id": 18558,982 "featured_link": null,983 "pinned_globally": false,984 "pinned_at": null,985 "pinned_until": null,986 "image_url": null,987 "slow_mode_seconds": 0,988 "draft": null,989 "draft_key": "topic_44986",990 "draft_sequence": null,991 "unpinned": null,992 "pinned": false,993 "current_post_number": 1,994 "highest_post_number": 3,995 "deleted_by": null,996 "actions_summary": [997 {998 "id": 4,999 "count": 0,1000 "hidden": false,1001 "can_act": false1002 },1003 {1004 "id": 8,1005 "count": 0,1006 "hidden": false,1007 "can_act": false1008 },1009 {1010 "id": 10,1011 "count": 0,1012 "hidden": false,1013 "can_act": false1014 },1015 {1016 "id": 7,1017 "count": 0,1018 "hidden": false,1019 "can_act": false1020 }1021 ],1022 "chunk_size": 20,1023 "bookmarked": false,1024 "topic_timer": null,1025 "message_bus_last_id": 0,1026 "participant_count": 2,1027 "show_read_indicator": false,1028 "thumbnails": null,1029 "slow_mode_enabled_until": null,1030 "can_vote": false,1031 "vote_count": 0,1032 "user_voted": false,1033 "discourse_zendesk_plugin_zendesk_id": null,1034 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",1035 "details": {1036 "can_edit": false,1037 "notification_level": 1,1038 "participants": [1039 {1040 "id": 18558,1041 "username": "dedf21972b190932c756",1042 "name": "윤 허",1043 "avatar_template": "/user_avatar/discuss.pytorch.org/dedf21972b190932c756/{size}/12023_2.png",1044 "post_count": 2,1045 "primary_group_name": null,1046 "flair_name": null,1047 "flair_url": null,1048 "flair_color": null,1049 "flair_bg_color": null,1050 "flair_group_id": null,1051 "trust_level": 11052 },1053 {1054 "id": 17564,1055 "username": "JamesTrick",1056 "name": "James Callinicos",1057 "avatar_template": "/user_avatar/discuss.pytorch.org/jamestrick/{size}/10956_2.png",1058 "post_count": 1,1059 "primary_group_name": null,1060 "flair_name": null,1061 "flair_url": null,1062 "flair_color": null,1063 "flair_bg_color": null,1064 "flair_group_id": null,1065 "trust_level": 21066 }1067 ],1068 "created_by": {1069 "id": 18558,1070 "username": "dedf21972b190932c756",1071 "name": "윤 허",1072 "avatar_template": "/user_avatar/discuss.pytorch.org/dedf21972b190932c756/{size}/12023_2.png"1073 },1074 "last_poster": {1075 "id": 18558,1076 "username": "dedf21972b190932c756",1077 "name": "윤 허",1078 "avatar_template": "/user_avatar/discuss.pytorch.org/dedf21972b190932c756/{size}/12023_2.png"1079 }1080 },1081 "bookmarks": []1082 },1083 {1084 "post_stream": {1085 "posts": [1086 {1087 "id": 110978,1088 "name": "",1089 "username": "hcl",1090 "avatar_template": "/letter_avatar_proxy/v4/letter/h/f04885/{size}.png",1091 "created_at": "2019-05-12T10:49:32.138Z",1092 "cooked": "<p>Background:I use DQN and DDPG to solve two tasks simultaneously. The <code>state(input)</code> of DQN and DDPG are both two parts. One part is the states of the environment, and the other one is the states abstracted from the environment by CNN+LSTM. The two parts are concatenate in <code>forward_dqn()</code> , <code>forward_actor()</code> and <code>forward_critic()</code> respectively.</p>\n<p>Question1: I backward propagate the <code>loss_dqn</code> , <code>loss_ddpg_actor</code> , and <code>loss_ddpg_critic</code> in sequence and get the error “Trying to backward through the graph a second time, but the buffers have already been freed.” in the backward propagation of <code>loss_ddpg_actor</code> . Since after the backward propagation of loss_dqn, the computational graph has been freed, so I have forward propagated CNN+LSTM again to calculate the loss_ddpg_actor. Why the computational graph cannot be created again? Thanks.<br>\n<img src=\"https://discuss.pytorch.org/uploads/default/original/2X/8/836209a982ecec4c1f2d463470e86104570a6779.png\" alt=\"%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20190512164242\" data-base62-sha1=\"iKgANvoyZVwKO1Z12Y95IwTahDz\" width=\"607\" height=\"323\"><br>\nModel: (env: environment)</p>\n<pre><code class=\"lang-auto\">output_cnnlstm = cnnlstm.forward(env)\nDQN_output = dqn.forward(cat(output_cnnlstm, state_env))\nActor_output = actor.forward(cat(output_cnnlstm, state_env))\nCritic_output = critic.forward(cat(output_cnnlstm, state_env))\n</code></pre>\n<p>Code 1 (Q1):</p>\n<pre><code class=\"lang-auto\"> # dqn\n # forward: cnnlstm\n s_cnnlstm_out, _, _ = self.model.forward_cnnlstm(s_cnnlstm, flag_optim=True)\n # forward: dqn\n q_eval_dqn = self.model.forward_dqn_eval(s_dqn, s_cnnlstm_out).gather(1, a_dqn)\n q_next_dqn = self.model.forward_dqn_target(s_dqn_next, s_cnnlstm_out).detach()\n q_target_dqn = r + GAMMA_DQN * q_next_dqn.max(dim=1)[0].reshape(SIZE_BATCH * SIZE_TRANSACTION, 1)\n # optimzie: dqn\n loss_dqn = self.loss_dqn(q_eval_dqn, q_target_dqn)\n self.optimizer_cnnlstm.zero_grad()\n self.optimizer_dqn.zero_grad()\n loss_dqn.backward()\n self.optimizer_cnnlstm.step()\n self.optimizer_dqn.step()\n loss_dqn = loss_dqn.detach().numpy()\n # ddpg\n # actor\n # forward: cnnlstm\n s_cnnlstm_out, _, _ = self.model.forward_cnnlstm(s_cnnlstm, flag_optim=True)\n # forward: ddpg: actor\n a_eval_ddpg = self.model.forward_actor_eval(s_ddpg, s_cnnlstm_out)\n # optimze: ddpg: cnnlstm + actor\n loss_ddpg_actor = - self.model.forward_cirtic_eval(s_ddpg, a_eval_ddpg, s_cnnlstm_out).mean()\n self.optimizer_cnnlstm.zero_grad()\n self.optimizer_actor.zero_grad()\n loss_ddpg_actor.backward()\n self.optimizer_cnnlstm.step()\n self.optimizer_actor.step()\n loss_ddpg_actor = loss_ddpg_actor.detach().numpy()\n</code></pre>\n<p>Question2: I write a demo to test the propagation process and the demo seems to work well since the loss descends normally and the test error is low. So I want to ask the difference between the two codes and models.</p>\n<p>Model:<br>\n<img src=\"https://discuss.pytorch.org/uploads/default/original/2X/f/f310c3ba08a8cddf70fd0e75134182cb470171f0.png\" alt=\"%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20190512164247\" data-base62-sha1=\"yGfWtJbEqN5DGYUYaUgMSaUuHLi\" width=\"467\" height=\"430\"></p>\n<pre><code class=\"lang-auto\">output_model1 = model1.forward(x)\noutput_model21 = model21.forward(cat(output_model1, x1))\noutput_model22 = model221.forward(cat(output_model1, x2))\n</code></pre>\n<p>compared with the model of Q1, output_model1 ~ cnnlstm, output_model21 ~ DQN, output_model22 ~ Actor</p>\n<p>Question3: I set breakpoint in the demo after <code>loss1.backward()</code> and before <code>optimizer1.step()</code> . However, on the one hand, the weight of the linear layer of Model21 changes with the optimization. On the other hand, <code>x._grad</code> is a gradient value tensor, while <code>x1._grad</code> is <code>None</code> . So I wonder the parameters of Model21 are optimized whether or not and why <code>x1._grad</code> is None.</p>\n<p>Code 2 (Q2 and Q3):</p>\n<pre><code class=\"lang-auto\">for i in range(NUM_OPTIM):\n # optimize task 1\n y1_pred = self.model.forward_task1(x, x1)\n loss1 = self.loss_21(y1_pred, y1)\n self.optimizer1.zero_grad()\n self.optimizer21.zero_grad()\n loss1.backward()\n self.optimizer1.step()\n self.optimizer21.step(\n # optimze task 2\n y2_pred = self.model.forward_task2(x, x2)\n loss2 = self.loss_22(y2_pred, y2)\n self.optimizer1.zero_grad()\n self.optimizer22.zero_grad()\n loss2.backward()\n self.optimizer1.step()\n self.optimizer22.step()\n</code></pre>",1093 "post_number": 1,1094 "post_type": 1,1095 "posts_count": 2,1096 "updated_at": "2019-05-12T10:49:32.138Z",1097 "reply_count": 0,1098 "reply_to_post_number": null,1099 "quote_count": 0,1100 "incoming_link_count": 23,1101 "reads": 14,1102 "readers_count": 13,1103 "score": 117.8,1104 "yours": false,1105 "topic_id": 45026,1106 "topic_slug": "can-not-create-a-new-calculation-graph-after-the-backward-propagation",1107 "display_username": "",1108 "primary_group_name": null,1109 "flair_name": null,1110 "flair_url": null,1111 "flair_bg_color": null,1112 "flair_color": null,1113 "flair_group_id": null,1114 "badges_granted": [],1115 "version": 1,1116 "can_edit": false,1117 "can_delete": false,1118 "can_recover": false,1119 "can_see_hidden_post": false,1120 "can_wiki": false,1121 "read": true,1122 "user_title": null,1123 "bookmarked": false,1124 "actions_summary": [],1125 "moderator": false,1126 "admin": false,1127 "staff": false,1128 "user_id": 18571,1129 "hidden": false,1130 "trust_level": 1,1131 "deleted_at": null,1132 "user_deleted": false,1133 "edit_reason": null,1134 "can_view_edit_history": true,1135 "wiki": false,1136 "post_url": "/t/can-not-create-a-new-calculation-graph-after-the-backward-propagation/45026/1",1137 "can_accept_answer": false,1138 "can_unaccept_answer": false,1139 "accepted_answer": false,1140 "topic_accepted_answer": null,1141 "can_vote": false1142 },1143 {1144 "id": 111266,1145 "name": "",1146 "username": "hcl",1147 "avatar_template": "/letter_avatar_proxy/v4/letter/h/f04885/{size}.png",1148 "created_at": "2019-05-14T02:01:32.440Z",1149 "cooked": "<p>My fault. I forget to <code>detach()</code> the hidden state and the cell state of LSTM from the computational graph in <code>self.model.forward_cnnlstm</code>.</p>",1150 "post_number": 2,1151 "post_type": 1,1152 "posts_count": 2,1153 "updated_at": "2019-05-14T02:01:32.440Z",1154 "reply_count": 0,1155 "reply_to_post_number": null,1156 "quote_count": 0,1157 "incoming_link_count": 1,1158 "reads": 9,1159 "readers_count": 8,1160 "score": 6.8,1161 "yours": false,1162 "topic_id": 45026,1163 "topic_slug": "can-not-create-a-new-calculation-graph-after-the-backward-propagation",1164 "display_username": "",1165 "primary_group_name": null,1166 "flair_name": null,1167 "flair_url": null,1168 "flair_bg_color": null,1169 "flair_color": null,1170 "flair_group_id": null,1171 "badges_granted": [],1172 "version": 1,1173 "can_edit": false,1174 "can_delete": false,1175 "can_recover": false,1176 "can_see_hidden_post": false,1177 "can_wiki": false,1178 "read": true,1179 "user_title": null,1180 "bookmarked": false,1181 "actions_summary": [],1182 "moderator": false,1183 "admin": false,1184 "staff": false,1185 "user_id": 18571,1186 "hidden": false,1187 "trust_level": 1,1188 "deleted_at": null,1189 "user_deleted": false,1190 "edit_reason": null,1191 "can_view_edit_history": true,1192 "wiki": false,1193 "post_url": "/t/can-not-create-a-new-calculation-graph-after-the-backward-propagation/45026/2",1194 "can_accept_answer": false,1195 "can_unaccept_answer": false,1196 "accepted_answer": false,1197 "topic_accepted_answer": null1198 }1199 ],1200 "stream": [