main/core.py
def save_model(model, loss, val_loss, fpath='', config={}, tstamp=''):
    '''Saves NN model object and associated information.

    inputs:
        model - a Keras model
        loss - list of training losses 
        val_loss - list of validation losses
        fpath - root filepath to save everything to (with .json, h5, png, info)
        config - the configuration dictionary that defined this model 
        tstamp - current timestamp to log in info file'''

    # Dump data
    with open(fpath + '.json', 'w') as structure_fpath:
        json.dump(model.to_json(), structure_fpath)
    print('...saved structural information')

    # Dump weights
    model.save_weights(fpath + '.h5', overwrite = True)
    print('...saved weights')

    # # Dump image
    # plot(model, to_file = fpath + '.png')
    # print('...saved image')

    # Dump history
    save_model_history_manual(loss, val_loss, fpath + '.hist')
    print ('...saved history')

    # Write to info file
    info_fid = open(fpath + '.info', 'a')
    info_fid.write('{} saved {}\n\n'.format(fpath, tstamp))
    info_fid.write('Configuration details\n------------\n')
    info_fid.write('  {}\n'.format(config))
    info_fid.close()

    print('...saved model to {}.[json, h5, png, info]'.format(fpath))
    return True
Saves NN model object and associated information.

    inputs:
        model - a Keras model
        loss - list of training losses 
        val_loss - list of validation losses
        fpath - root filepath to save everything to (with .json, h5, png, info)
        config - the configuration dictionary that defined this model 
        tstamp - current timestamp to log in info file
Saves NN model object and associated information.
Saves NN model object and associated information .
def save_model(model, loss, val_loss, fpath='', config={}, tstamp=''):
    with open(fpath + '.json', 'w') as structure_fpath:
        json.dump(model.to_json(), structure_fpath)
    print('...saved structural information')
    model.save_weights(fpath + '.h5', overwrite = True)
    print('...saved weights')
    save_model_history_manual(loss, val_loss, fpath + '.hist')
    print ('...saved history')
    info_fid = open(fpath + '.info', 'a')
    info_fid.write('{} saved {}\n\n'.format(fpath, tstamp))
    info_fid.write('Configuration details\n------------\n')
    info_fid.write('  {}\n'.format(config))
    info_fid.close()
    print('...saved model to {}.[json, h5, png, info]'.format(fpath))
    return True
def save_model ( model , loss , val_loss , fpath = '' , config = { } , tstamp = '' ) : with open ( fpath + '.json' , 'w' ) as structure_fpath : json . dump ( model . to_json ( ) , structure_fpath ) print ( '...saved structural information' ) model . save_weights ( fpath + '.h5' , overwrite = True ) print ( '...saved weights' ) save_model_history_manual ( loss , val_loss , fpath + '.hist' ) print ( '...saved history' ) info_fid = open ( fpath + '.info' , 'a' ) info_fid . write ( '{} saved {}\n\n' . format ( fpath , tstamp ) ) info_fid . write ( 'Configuration details\n------------\n' ) info_fid . write ( '  {}\n' . format ( config ) ) info_fid . close ( ) print ( '...saved model to {}.[json, h5, png, info]' . format ( fpath ) ) return True
Saves NN model object and associated information.
Saves NN model object and associated information .
'''Saves NN model object and associated information.

    inputs:
        model - a Keras model
        loss - list of training losses 
        val_loss - list of validation losses
        fpath - root filepath to save everything to (with .json, h5, png, info)
        config - the configuration dictionary that defined this model 
        tstamp - current timestamp to log in info file''' # Dump data # Dump weights # # Dump image # plot(model, to_file = fpath + '.png') # print('...saved image') # Dump history # Write to info file
model
loss
val_loss
fpath
config
tstamp