简体   繁体   中英

Visualizing saved weights from neural network inside folder directory

I'm trying to get the grip around the neural network weights in keras, and i am successfully saving mine while using kaggle notebooks. Now, what i want to do is visualize or load it, but since it's saving dynamically per iteration, it'll have different names, so i can't specifically find them.

My saving path:

checkpoint_filepath = '../input/groupsdata/model-{epoch:03d}-{accuracy:03f}-{val_accuracy:03f}.h5'
checkpoint = ModelCheckpoint(checkpoint_filepath, verbose=1, monitor='val_acc', save_weights_only=True, save_best_only=True, mode='auto')
model.fit(train_ds, validation_data=test_ds, epochs=100, batch_size=n_batch, callbacks=[checkpoint], verbose=0)

在此处输入图片说明

My problem is that, the weights are not visible apparently in the directory where i saved them. I would like to know how do i visualize the file and how do i load them?

A good solution for my problem was using checkpoints, following the documentation:

checkpoint_path = "./cp-{epoch:04d}.ckpt"
checkpoint_dir = os.path.dirname(checkpoint_path)
cp_callback = tf.keras.callbacks.ModelCheckpoint(
    filepath=checkpoint_path, 
    verbose=1, 
    save_weights_only=True,
    save_best_only=True,
    monitor='val_acc',
    period=5)

This way, in kaggle, i could easily view the output by doing:

ls {checkpoint_dir}

More over to get the latest checkpoint:

latest = tf.train.latest_checkpoint(checkpoint_dir)
latest.

I was having problems with visualizing other weight formats such as json, h5 and hdf5, but .ckpt can be visualized just fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM