load multi-modal data with pytorchModel summary in pytorchmulti-variable linear regression with pytorchHow do I load up an image and convert it to a proper tensor for PyTorch?MemoryError when attempting to create a docker image with Torch/PyTorchMulti label classification in pytorchUpdating pre-trained Deep Learning model with respect to new data pointsPyTorch - loading images without sub foldersLoad data from CSV using DataLoaderPytorch torchvision MNIST downloadinteger argument expected, got float Pytorch : transform

What is the difference between "Plural" and "Mehrzahl"?

How to slow yourself down (for playing nice with others)

Can I do brevets (long distance rides) on my hybrid bike? If yes, how to start?

Why does a C.D.F need to be right-continuous?

Is a diamond sword feasible?

"Fīliolō me auctum scito, salva Terentia"; what is "me" role in this phrase?

Does the sorcerer's Subtle Spell Metamagic option allow you to ignore both Verbal and Somatic components?

How do I tell my supervisor that he is choosing poor replacements for me while I am on maternity leave?

51% attack - apparently very easy? refering to CZ's "rollback btc chain" - How to make sure such corruptible scenario can never happen so easily?

Why do Thanos's punches not kill Captain America or at least cause some mortal injuries?

Noob at soldering, can anyone explain why my circuit won't work?

Would an 8% reduction in drag outweigh the weight addition from this custom CFD-tested winglet?

Guns in space with bullets that return?

How to pronounce "r" after a "g"?

What is the significance of 4200 BCE in context of farming replacing foraging in Europe?

Was the Highlands Ranch shooting the 115th mass shooting in the US in 2019

Delta TSA-Precheck status removed

Why was this sacrifice sufficient?

Pre-1993 comic in which Wolverine's claws were turned to rubber?

How can a Lich look like a human without magic?

Can the sorting of a list be verified without comparing neighbors?

How are one-time password generators like Google Authenticator different from having two passwords?

Should these notes be played as a chord or one after another?

Two researchers want to work on the same extension to my paper. Who to help?



load multi-modal data with pytorch


Model summary in pytorchmulti-variable linear regression with pytorchHow do I load up an image and convert it to a proper tensor for PyTorch?MemoryError when attempting to create a docker image with Torch/PyTorchMulti label classification in pytorchUpdating pre-trained Deep Learning model with respect to new data pointsPyTorch - loading images without sub foldersLoad data from CSV using DataLoaderPytorch torchvision MNIST downloadinteger argument expected, got float Pytorch : transform






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I'm trying to load multi-modal data (e.g. text and image) in pytorch for image classification. I do not know how to load them simultaneously, like the following code.



 def __init__(self, img_path, txt_path, transform=None, loader=default_loader):

def __len__(self):
return len(self.img_name)

def __getitem__(self, item):


Can anyone help me?










share|improve this question




























    1















    I'm trying to load multi-modal data (e.g. text and image) in pytorch for image classification. I do not know how to load them simultaneously, like the following code.



     def __init__(self, img_path, txt_path, transform=None, loader=default_loader):

    def __len__(self):
    return len(self.img_name)

    def __getitem__(self, item):


    Can anyone help me?










    share|improve this question
























      1












      1








      1








      I'm trying to load multi-modal data (e.g. text and image) in pytorch for image classification. I do not know how to load them simultaneously, like the following code.



       def __init__(self, img_path, txt_path, transform=None, loader=default_loader):

      def __len__(self):
      return len(self.img_name)

      def __getitem__(self, item):


      Can anyone help me?










      share|improve this question














      I'm trying to load multi-modal data (e.g. text and image) in pytorch for image classification. I do not know how to load them simultaneously, like the following code.



       def __init__(self, img_path, txt_path, transform=None, loader=default_loader):

      def __len__(self):
      return len(self.img_name)

      def __getitem__(self, item):


      Can anyone help me?







      pytorch






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 22 at 15:11









      xiaodan zhangxiaodan zhang

      61




      61






















          2 Answers
          2






          active

          oldest

          votes


















          0














          In __getitem__, you can use a dictionary or a tuple to represent one sample of your data. Later during training when you create a dataloader using the dataset, pytorch will automatically create batches of dictonary or tuples.



          If you want to create samples in a much more different way, check out collate_fn in pytorch.






          share|improve this answer






























            0














            The method getitem(self, item) would help you do this.



            For example:



            def __getitem__(self, item): # item can be thought as an index

            text = textList[item] # textList would be a list containing the text you want to input into the model for element 'item'
            img = imgList[image] # imgList would be a list containing the images you want to input into the model for element 'item'

            input = [text, img]
            y = labels[item] # labels would be a list containing the label for the input of the text and img. This is your target.

            return input, y





            share|improve this answer























            • Thanks for your reply. I will try it.

              – xiaodan zhang
              Mar 24 at 8:48











            • if it is fixed please mark my answer as correct

              – asong24
              Mar 24 at 14:31











            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55302653%2fload-multi-modal-data-with-pytorch%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            In __getitem__, you can use a dictionary or a tuple to represent one sample of your data. Later during training when you create a dataloader using the dataset, pytorch will automatically create batches of dictonary or tuples.



            If you want to create samples in a much more different way, check out collate_fn in pytorch.






            share|improve this answer



























              0














              In __getitem__, you can use a dictionary or a tuple to represent one sample of your data. Later during training when you create a dataloader using the dataset, pytorch will automatically create batches of dictonary or tuples.



              If you want to create samples in a much more different way, check out collate_fn in pytorch.






              share|improve this answer

























                0












                0








                0







                In __getitem__, you can use a dictionary or a tuple to represent one sample of your data. Later during training when you create a dataloader using the dataset, pytorch will automatically create batches of dictonary or tuples.



                If you want to create samples in a much more different way, check out collate_fn in pytorch.






                share|improve this answer













                In __getitem__, you can use a dictionary or a tuple to represent one sample of your data. Later during training when you create a dataloader using the dataset, pytorch will automatically create batches of dictonary or tuples.



                If you want to create samples in a much more different way, check out collate_fn in pytorch.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 23 at 10:42









                shivam2298shivam2298

                184




                184























                    0














                    The method getitem(self, item) would help you do this.



                    For example:



                    def __getitem__(self, item): # item can be thought as an index

                    text = textList[item] # textList would be a list containing the text you want to input into the model for element 'item'
                    img = imgList[image] # imgList would be a list containing the images you want to input into the model for element 'item'

                    input = [text, img]
                    y = labels[item] # labels would be a list containing the label for the input of the text and img. This is your target.

                    return input, y





                    share|improve this answer























                    • Thanks for your reply. I will try it.

                      – xiaodan zhang
                      Mar 24 at 8:48











                    • if it is fixed please mark my answer as correct

                      – asong24
                      Mar 24 at 14:31















                    0














                    The method getitem(self, item) would help you do this.



                    For example:



                    def __getitem__(self, item): # item can be thought as an index

                    text = textList[item] # textList would be a list containing the text you want to input into the model for element 'item'
                    img = imgList[image] # imgList would be a list containing the images you want to input into the model for element 'item'

                    input = [text, img]
                    y = labels[item] # labels would be a list containing the label for the input of the text and img. This is your target.

                    return input, y





                    share|improve this answer























                    • Thanks for your reply. I will try it.

                      – xiaodan zhang
                      Mar 24 at 8:48











                    • if it is fixed please mark my answer as correct

                      – asong24
                      Mar 24 at 14:31













                    0












                    0








                    0







                    The method getitem(self, item) would help you do this.



                    For example:



                    def __getitem__(self, item): # item can be thought as an index

                    text = textList[item] # textList would be a list containing the text you want to input into the model for element 'item'
                    img = imgList[image] # imgList would be a list containing the images you want to input into the model for element 'item'

                    input = [text, img]
                    y = labels[item] # labels would be a list containing the label for the input of the text and img. This is your target.

                    return input, y





                    share|improve this answer













                    The method getitem(self, item) would help you do this.



                    For example:



                    def __getitem__(self, item): # item can be thought as an index

                    text = textList[item] # textList would be a list containing the text you want to input into the model for element 'item'
                    img = imgList[image] # imgList would be a list containing the images you want to input into the model for element 'item'

                    input = [text, img]
                    y = labels[item] # labels would be a list containing the label for the input of the text and img. This is your target.

                    return input, y






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Mar 24 at 4:10









                    asong24asong24

                    234




                    234












                    • Thanks for your reply. I will try it.

                      – xiaodan zhang
                      Mar 24 at 8:48











                    • if it is fixed please mark my answer as correct

                      – asong24
                      Mar 24 at 14:31

















                    • Thanks for your reply. I will try it.

                      – xiaodan zhang
                      Mar 24 at 8:48











                    • if it is fixed please mark my answer as correct

                      – asong24
                      Mar 24 at 14:31
















                    Thanks for your reply. I will try it.

                    – xiaodan zhang
                    Mar 24 at 8:48





                    Thanks for your reply. I will try it.

                    – xiaodan zhang
                    Mar 24 at 8:48













                    if it is fixed please mark my answer as correct

                    – asong24
                    Mar 24 at 14:31





                    if it is fixed please mark my answer as correct

                    – asong24
                    Mar 24 at 14:31

















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55302653%2fload-multi-modal-data-with-pytorch%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현