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

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript