def test_NN_ExportImportWeights(): typ = "STD" NN1 = NN.clsNN(3,1,4,Type=typ) NN2 = NN.clsNN(3,1,4,Type=typ) # NN.ModelFit(NN1.model[0],x1,f20(x1), Epochs=10, ReTry=100, StopAt=[1.0e-2]) NN.ExportModelWeights(NN1.model[0],"csv/test/exports/","TestNN_ImpExp" + typ + "_") for i in range(1,3): w1 = list(NN1.model[0].layers[i].get_weights()[0][0]) w2 = list(NN2.model[0].layers[i].get_weights()[0][0]) assert not w1 == w2 NN.ImportModelWeights(NN2.model[0],"csv/test/exports/TestNN_ImpExp" + typ + "_3-relu64-linear4.h5") for i in range(1,3): w1 = list(NN1.model[0].layers[i].get_weights()[0][0]) w2 = list(NN2.model[0].layers[i].get_weights()[0][0]) assert w1 == w2, "layer " + str(i) + " weights not identical"
def xQModelExportWeights(self, path, prefix): if self.QModelType == "QSAI": NN.ExportModelWeights(self.QModel[0], path, prefix + "_")