mirror of
https://github.com/marian-nmt/marian.git
synced 2024-09-17 09:47:34 +03:00
Add initial version of validation
This commit is contained in:
parent
67e717d366
commit
269936a4a8
@ -53,13 +53,18 @@ class NpzConverter {
|
|||||||
destructed_ = true;
|
destructed_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Load(const std::string& key, marian::Tensor& tensor) const {
|
void Load(const std::string& key, std::vector<float>& data, marian::Shape& shape) const {
|
||||||
auto it = model_.find(key);
|
auto it = model_.find(key);
|
||||||
if(it != model_.end()) {
|
if(it != model_.end()) {
|
||||||
NpyMatrixWrapper np(it->second);
|
NpyMatrixWrapper np(it->second);
|
||||||
tensor.allocate({(int)np.size1(), (int)np.size2()});
|
data.clear();
|
||||||
std::vector<float> data(np.data(), np.data() + np.size());
|
data.resize(np.size());
|
||||||
tensor.Load(data);
|
std::copy(np.data(), np.data() + np.size(), data.begin());
|
||||||
|
|
||||||
|
shape.clear();
|
||||||
|
shape.push_back(np.size1());
|
||||||
|
shape.push_back(np.size2());
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::cerr << "Missing " << key << std::endl;
|
std::cerr << "Missing " << key << std::endl;
|
||||||
|
Loading…
Reference in New Issue
Block a user