public void load_weights(string filepath, bool by_name = false, bool skip_mismatch = false, object options = null) { long fileId = Hdf5.OpenFile(filepath, true); if (fileId < 0) { tf_output_redirect.WriteLine($"Can't find weights file {filepath}"); return; } bool msuccess = Hdf5.GroupExists(fileId, "model_weights"); bool lsuccess = Hdf5.GroupExists(fileId, "layer_names"); if (!lsuccess && msuccess) { fileId = H5G.open(fileId, "model_weights"); } if (by_name) { //fdf5_format.load_weights_from_hdf5_group_by_name(); throw new NotImplementedException(""); } else { hdf5_format.load_weights_from_hdf5_group(fileId, Layers); Hdf5.CloseFile(fileId); } }
public List <(IVariableV1, NDArray)> load_weights(string filepath, bool by_name = false, bool skip_mismatch = false, object options = null) { long fileId = Hdf5.OpenFile(filepath, true); bool msuccess = Hdf5.GroupExists(fileId, "model_weights"); bool lsuccess = Hdf5.GroupExists(fileId, "layer_names"); if (!lsuccess && msuccess) { fileId = H5G.open(fileId, "model_weights"); } if (by_name) { //fdf5_format.load_weights_from_hdf5_group_by_name(); throw new NotImplementedException(""); } else { var weights = hdf5_format.load_weights_from_hdf5_group(fileId, Layers); Hdf5.CloseFile(fileId); // return a reference to prevent GC collect Variable. return(weights); } }
public void ReadSystemEvents() { string groupName = rootName + eventsName; if (Hdf5.GroupExists(fileId, groupName)) { var e = Hdf5.ReadCompounds <SystemEvent>(fileId, groupName, ""); Events.AddRange(e); } }
public void WriteAndReadGroupsWithDataset() { string filename = Path.Combine(folder, "testGroups.H5"); try { var fileId = Hdf5.CreateFile(filename); Assert.IsTrue(fileId > 0); var dset = dsets.First(); var groupId = H5G.create(fileId, "/A"); ///B/C/D/E/F/G/H Hdf5.WriteDataset(groupId, "test", dset); var subGroupId = Hdf5.CreateGroup(groupId, "C"); var subGroupId2 = Hdf5.CreateGroup(groupId, "/D"); // will be saved at the root location dset = dsets.Skip(1).First(); Hdf5.WriteDataset(subGroupId, "test2", dset); Hdf5.CloseGroup(subGroupId); Hdf5.CloseGroup(subGroupId2); Hdf5.CloseGroup(groupId); groupId = H5G.create(fileId, "/A/B"); ///B/C/D/E/F/G/H dset = dsets.Skip(1).First(); Hdf5.WriteDataset(groupId, "test", dset); Hdf5.CloseGroup(groupId); groupId = Hdf5.CreateGroupRecursively(fileId, "A/B/C/D/E/F/I"); Hdf5.CloseGroup(groupId); Hdf5.CloseFile(fileId); fileId = Hdf5.OpenFile(filename); Assert.IsTrue(fileId > 0); groupId = H5G.open(fileId, "/A/B"); double[,] dset2 = (double[, ])Hdf5.ReadDataset <double>(groupId, "test"); CompareDatasets(dset, dset2); Assert.IsTrue(Hdf5.CloseGroup(groupId) >= 0); groupId = H5G.open(fileId, "/A/C"); dset2 = (double[, ])Hdf5.ReadDataset <double>(groupId, "test2"); CompareDatasets(dset, dset2); Assert.IsTrue(Hdf5.CloseGroup(groupId) >= 0); bool same = dset == dset2; dset = dsets.First(); dset2 = (double[, ])Hdf5.ReadDataset <double>(fileId, "/A/test"); CompareDatasets(dset, dset2); Assert.IsTrue(Hdf5.GroupExists(fileId, "A/B/C/D/E/F/I")); Assert.IsTrue(Hdf5.CloseFile(fileId) == 0); } catch (Exception ex) { CreateExceptionAssert(ex); } }
public void ReadPatientInformation() { string groupName = rootName + patient_informationName; if (Hdf5.GroupExists(fileId, groupName)) { PatientInformation = Hdf5.ReadObject <Patient>(fileId, groupName); return; } groupName = rootNameOld + patient_informationName; if (Hdf5.GroupExists(fileId, groupName)) { PatientInformation = Hdf5.ReadObject <Patient>(fileId, groupName); } }
public void ReadProcedureInformation() { string groupName = rootName + procedure_informationName; if (Hdf5.GroupExists(fileId, groupName)) { ProcedureInformation = Hdf5.ReadObject <ProcedureInformation>(fileId, groupName); return; } groupName = rootNameOld + procedure_informationName; if (Hdf5.GroupExists(fileId, groupName)) { ProcedureInformation = Hdf5.ReadObject <ProcedureInformation>(fileId, groupName); } }
public void ReadSystemInformation() { string groupName = rootName + system_informationName; if (Hdf5.GroupExists(fileId, groupName)) { SystemInformation = Hdf5.ReadObject <SystemInformation>(fileId, groupName); return; } groupName = rootNameOld + system_informationName; if (Hdf5.GroupExists(fileId, groupName)) { SystemInformation = Hdf5.ReadObject <SystemInformation>(fileId, groupName); } }
public void ReadECGData() { string groupName = rootName + ecgName; if (Hdf5.GroupExists(fileId, groupName)) { ECG = Hdf5.ReadObject <ECGData>(fileId, groupName); return; } groupName = rootNameOld + ecgName; if (Hdf5.GroupExists(fileId, groupName)) { ECG = Hdf5.ReadObject <ECGData>(fileId, groupName); } }
public void ReadEITData() { int index = 1; string rootGroup = rootName + eitName; if (!Hdf5.GroupExists(fileId, rootGroup)) { rootGroup = rootNameOld + eitName; } while (Hdf5.GroupExists(fileId, rootGroup + "/d" + index)) { var entry = Hdf5.ReadObject <EITEntry>(fileId, rootGroup + "/d" + index); EITs.Add(entry); index++; } }