Using python tensorflow to Load Files Saved in tf Format

Asked 1 years ago, Updated 1 years ago, 415 views

I am currently doing deep learning using python tensorflow.
I saved the weight I learned in training dataset in tf format, but I can't take it out.
I'd like to ask for your advice.

First, I will explain it in the toy program below, and lastly, I will ask you a question.

 from model import get_model
    
model=None
model=get_model()

fn = "tmp3/test55.tf";

"""
1. Let them learn in the middle
2. Don't let them learn
"""

# for preservation
model.save_weights(fn)
# for loading
model.load_weights(fn)

Running the above program generates three files under the ./tmp3 directory.

checkpoint
test55.tf.data-00000-of-00001
test55.tf.index

I had no problem loading these files when I didn't let them learn 2.
However, the same file was created when 1 was learned, but it could not be loaded successfully.

The error message is as follows:

2021-09-13 23:37:12.127153:Itensorflow/core/common_runtime/gpu/gpu_device.cc:1510] Created device/job:localhost/replica:0/task:0/device:GPU:0 with 10801MB memory:->device:0, name: Tesla K80, pcius.cuity:06 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00
Exception ignored in: <function_CheckpointRestoreCoordinatorDelete.__del__at0x2aad0724c160>
Traceback (most recent call last):
  File"/cluster/XXX/miniconda/lib/python 3.8/site-packages/tensorflow/python/training/tracking/util.py", line 200, in_del__
TypeError: 'NoneType' object is not callable

Question

There is an error with or without learning, but is there any way to read the file I learned?
I would like to know why this error occurs for future study.

Sorry for the inconvenience, but I appreciate your cooperation

python tensorflow

2022-09-30 21:59

1 Answers

As stated in the above comment, I am referring to your reply.

I was able to confirm that it works properly by modifying the following parts of the toy program above.
There may be people who are having trouble with similar problems in the future, so
I will write it down for recording.

#For loading
model.load_weights(fn)#< - Where is the problem?

I was able to load the file without any problems by changing the part below.

model.load_weights(fn).expect_partial()#<- Solution


2022-09-30 21:59

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.