diff --git a/GPy/core/parameterization/parameter_core.py b/GPy/core/parameterization/parameter_core.py index a8f11606..6add95b0 100644 --- a/GPy/core/parameterization/parameter_core.py +++ b/GPy/core/parameterization/parameter_core.py @@ -1010,9 +1010,9 @@ class Parameterizable(OptimizationHandlable): """ pass - def save_params_H5(self, filename): + def save(self, filename, ftype='HDF5'): """ - Save all the model parameters into a HDF5 file. + Save all the model parameters into a file (HDF5 by default). """ from . import Param from ...util.misc import param_to_array @@ -1022,15 +1022,16 @@ class Parameterizable(OptimizationHandlable): plist = [] self.traverse(gather_params, plist) names = self.parameter_names(adjust_for_printing=True) - try: - import h5py - f = h5py.File(filename,'w') - for p,n in zip(plist,names): - n = n.replace('.','_') - p = param_to_array(p) - d = f.create_dataset(n,p.shape,dtype=p.dtype) - d[:] = p - f.close() - except: - raise 'Fails to write the parameters into a HDF5 file!' + if ftype=='HDF5': + try: + import h5py + f = h5py.File(filename,'w') + for p,n in zip(plist,names): + n = n.replace('.','_') + p = param_to_array(p) + d = f.create_dataset(n,p.shape,dtype=p.dtype) + d[:] = p + f.close() + except: + raise 'Fails to write the parameters into a HDF5 file!'