[mlpack-git] master: Re-initialize DatasetInfo on load. (51441e2)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Wed Dec 23 11:44:25 EST 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/de9cc4b05069e1fa4793d9355f2f595af5ff45d2...6070527af14296cd99739de6c62666cc5d2a2125

>---------------------------------------------------------------

commit 51441e2b4d4b255a3e7d7cbc77df35b9f8f5c00e
Author: Ryan Curtin <ryan at ratml.org>
Date:   Sat Oct 17 09:58:47 2015 -0400

    Re-initialize DatasetInfo on load.


>---------------------------------------------------------------

51441e2b4d4b255a3e7d7cbc77df35b9f8f5c00e
 src/mlpack/core/data/load.hpp      | 3 +++
 src/mlpack/core/data/load_impl.hpp | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/src/mlpack/core/data/load.hpp b/src/mlpack/core/data/load.hpp
index 3e04e6a..99181bb 100644
--- a/src/mlpack/core/data/load.hpp
+++ b/src/mlpack/core/data/load.hpp
@@ -81,6 +81,9 @@ bool Load(const std::string& filename,
  * mlpack requires column-major matrices, this should be left at its default
  * value of 'true'.
  *
+ * The DatasetInfo object passed to this function will be re-created, so any
+ * mappings from previous loads will be lost.
+ *
  * @param filename Name of file to load.
  * @param matrix Matrix to load contents of file into.
  * @param info DatasetInfo object to populate with mappings and data types.
diff --git a/src/mlpack/core/data/load_impl.hpp b/src/mlpack/core/data/load_impl.hpp
index 4f953b5..2a37659 100644
--- a/src/mlpack/core/data/load_impl.hpp
+++ b/src/mlpack/core/data/load_impl.hpp
@@ -340,9 +340,15 @@ bool Load(const std::string& filename,
 
     // Now we have the size.  So resize our matrix.
     if (transpose)
+    {
       matrix.set_size(cols, rows);
+      info = DatasetInfo(rows);
+    }
     else
+    {
       matrix.set_size(rows, cols);
+      info = DatasetInfo(cols);
+    }
 
     stream.close();
     stream.open(filename, std::fstream::in);



More information about the mlpack-git mailing list