auto model1 = MLP!(float, HostStorage)(3);
model1.save("/tmp/test_grain0.h5");
auto model2 = MLP!(float, HostStorage)(3);
model2.load("/tmp/test_grain0.h5");
assert(model1.fc1.bias.sliced == model2.fc1.bias.sliced);
import numir;
import mir.ndslice;
auto x = uniform!float(3, 2).slice.variable;
assert(model1(x).sliced == model2(x).sliced);
auto model1 = MLP!(float, DeviceStorage)(3);
model1.save("/tmp/test_grain1.h5");
auto model2 = MLP!(float, DeviceStorage)(3);
model2.load("/tmp/test_grain1.h5");
assert(model1.fc1.bias.to!HostStorage.sliced == model2.fc1.bias.to!HostStorage
.sliced);
import numir;
import mir.ndslice;
auto x = uniform!float(3, 2).slice.variable.to!DeviceStorage;
assert(model1(x).to!HostStorage.sliced == model2(x).to!HostStorage.sliced);
auto model1 = MLP!(float, HostStorage)(3);
model1.save("/tmp/test_grain2.h5");
auto model2 = MLP!(float, DeviceStorage)(3);
model2.load("/tmp/test_grain2.h5");
assert(model1.fc1.bias.to!HostStorage.sliced == model2.fc1.bias.to!HostStorage
.sliced);
auto model1 = MLP!(float, DeviceStorage)(3);
model1.save("/tmp/test_grain3.h5");
auto model2 = MLP!(float, HostStorage)(3);
model2.load("/tmp/test_grain3.h5");
assert(model1.fc1.bias.to!HostStorage.sliced == model2.fc1.bias.to!HostStorage
.sliced);
load chain parameters from HDF5 path