Last active
May 29, 2018 15:52
-
-
Save marty1885/be5c822bb3f8883346be392d1fbe98cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
decltype(auto) convertDataset(const xt::xarray<float>& X, const xt::xarray<float>& Y) | |
{ | |
size_t numData = X.shape()[0]; | |
std::vector<vec_t> x(numData); | |
std::vector<label_t> y(numData); | |
for(size_t i=0;i<numData;i++) | |
{ | |
auto xb = xt::view(X, i, xt::all()); | |
x[i] = vec_t(xb.begin(), xb.end()); | |
auto yb = xt::view(Y, i, xt::all()); | |
y[i] = xt::argmax(yb)[0]; | |
} | |
//shuffle dataset | |
shuffle(x.begin(), x.end(), std::mt19937(42)); | |
shuffle(y.begin(), y.end(), std::mt19937(42)); | |
return std::tuple(x, y); | |
} | |
auto [x, y] = convertDataset(X, Y); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment