What is the right way to import data to tensorflow?











up vote
0
down vote

favorite












I am new to Tensorflow and trying to make my own little project. I would like to import my CSV file as a dataset and then I would like to split it into training and testing sets and also to be able to make batches from my dataset.

My CSV file contains 3 columns of numbers so I managed to find these lines of code



filenames = ['mydata.csv']
record_defaults = [tf.float32] * 3
dataset = tf.contrib.data.CsvDataset(filenames, record_defaults, header=True, select_cols=[1,2,3])


How do I convert this object to tensor or dataset, so I can either split the data or create batches of data?










share|improve this question




























    up vote
    0
    down vote

    favorite












    I am new to Tensorflow and trying to make my own little project. I would like to import my CSV file as a dataset and then I would like to split it into training and testing sets and also to be able to make batches from my dataset.

    My CSV file contains 3 columns of numbers so I managed to find these lines of code



    filenames = ['mydata.csv']
    record_defaults = [tf.float32] * 3
    dataset = tf.contrib.data.CsvDataset(filenames, record_defaults, header=True, select_cols=[1,2,3])


    How do I convert this object to tensor or dataset, so I can either split the data or create batches of data?










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am new to Tensorflow and trying to make my own little project. I would like to import my CSV file as a dataset and then I would like to split it into training and testing sets and also to be able to make batches from my dataset.

      My CSV file contains 3 columns of numbers so I managed to find these lines of code



      filenames = ['mydata.csv']
      record_defaults = [tf.float32] * 3
      dataset = tf.contrib.data.CsvDataset(filenames, record_defaults, header=True, select_cols=[1,2,3])


      How do I convert this object to tensor or dataset, so I can either split the data or create batches of data?










      share|improve this question















      I am new to Tensorflow and trying to make my own little project. I would like to import my CSV file as a dataset and then I would like to split it into training and testing sets and also to be able to make batches from my dataset.

      My CSV file contains 3 columns of numbers so I managed to find these lines of code



      filenames = ['mydata.csv']
      record_defaults = [tf.float32] * 3
      dataset = tf.contrib.data.CsvDataset(filenames, record_defaults, header=True, select_cols=[1,2,3])


      How do I convert this object to tensor or dataset, so I can either split the data or create batches of data?







      python tensorflow






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 17 at 16:41









      Matthieu Brucher

      6,7891331




      6,7891331










      asked Nov 17 at 15:23









      Crash

      276




      276
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          Use a tool to split your data like sklearn.model_selection.train_test_split:



          X_train, X_test, y_train, y_test = train_test_split(
          dataset[:2], dataset[2], test_size=0.33, random_state=42)


          For instance if your dataset consists of two features columns and one output label.






          share|improve this answer




























            up vote
            0
            down vote













            As explained on the tensorflow guide here , you have the dataset and after this you can preprocess your data using the Dataset.map() transformation for a certain defined function. Batching and shuffling could also be done after wards using dataset.batch(Batch_size) and dataset.shuffle(buffer_size=Buffer_Size). you can read the guide for further details.






            share|improve this answer





















              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',
              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%2f53352604%2fwhat-is-the-right-way-to-import-data-to-tensorflow%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








              up vote
              0
              down vote













              Use a tool to split your data like sklearn.model_selection.train_test_split:



              X_train, X_test, y_train, y_test = train_test_split(
              dataset[:2], dataset[2], test_size=0.33, random_state=42)


              For instance if your dataset consists of two features columns and one output label.






              share|improve this answer

























                up vote
                0
                down vote













                Use a tool to split your data like sklearn.model_selection.train_test_split:



                X_train, X_test, y_train, y_test = train_test_split(
                dataset[:2], dataset[2], test_size=0.33, random_state=42)


                For instance if your dataset consists of two features columns and one output label.






                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  Use a tool to split your data like sklearn.model_selection.train_test_split:



                  X_train, X_test, y_train, y_test = train_test_split(
                  dataset[:2], dataset[2], test_size=0.33, random_state=42)


                  For instance if your dataset consists of two features columns and one output label.






                  share|improve this answer












                  Use a tool to split your data like sklearn.model_selection.train_test_split:



                  X_train, X_test, y_train, y_test = train_test_split(
                  dataset[:2], dataset[2], test_size=0.33, random_state=42)


                  For instance if your dataset consists of two features columns and one output label.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 17 at 16:43









                  Matthieu Brucher

                  6,7891331




                  6,7891331
























                      up vote
                      0
                      down vote













                      As explained on the tensorflow guide here , you have the dataset and after this you can preprocess your data using the Dataset.map() transformation for a certain defined function. Batching and shuffling could also be done after wards using dataset.batch(Batch_size) and dataset.shuffle(buffer_size=Buffer_Size). you can read the guide for further details.






                      share|improve this answer

























                        up vote
                        0
                        down vote













                        As explained on the tensorflow guide here , you have the dataset and after this you can preprocess your data using the Dataset.map() transformation for a certain defined function. Batching and shuffling could also be done after wards using dataset.batch(Batch_size) and dataset.shuffle(buffer_size=Buffer_Size). you can read the guide for further details.






                        share|improve this answer























                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          As explained on the tensorflow guide here , you have the dataset and after this you can preprocess your data using the Dataset.map() transformation for a certain defined function. Batching and shuffling could also be done after wards using dataset.batch(Batch_size) and dataset.shuffle(buffer_size=Buffer_Size). you can read the guide for further details.






                          share|improve this answer












                          As explained on the tensorflow guide here , you have the dataset and after this you can preprocess your data using the Dataset.map() transformation for a certain defined function. Batching and shuffling could also be done after wards using dataset.batch(Batch_size) and dataset.shuffle(buffer_size=Buffer_Size). you can read the guide for further details.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 19 at 14:52









                          D.negn

                          262




                          262






























                               

                              draft saved


                              draft discarded



















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53352604%2fwhat-is-the-right-way-to-import-data-to-tensorflow%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

                              "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                              Alcedinidae

                              Origin of the phrase “under your belt”?