Skip to content

Unable to load saved model #4

Description

@Masquerade0097

I saved the model after training using the following commands

saver = tf.train.Saver()
saver.save(sess, '../data/output/'+folder_name+'/model/var_autoencoder_model')

Then in another test script, I restored the model using the following commands

saver = tf.train.import_meta_graph('../data/output/'+folder_name+'/model/var_autoencoder_model.meta')
saver.restore(sess, '../data/output/'+folder_name+'/model/var_autoencoder_model')

But the model is failing with the following error

Caused by op 'Variable_9/read', defined at:
  File "test.py", line 581, in <module>
    train_data = initialize_autoencoder_data(folder_name, search)
  File "test.py", line 413, in initialize_autoencoder_data
    model = VDSH(sess, latent_dim, x_train.shape[1])
  File "/home/admin1/3/SourceCodeAnalytics-master/src/VDSH.py", line 27, in __init__
    self.build()
  File "/home/admin1/3/SourceCodeAnalytics-master/src/VDSH.py", line 94, in build
    self.z_enc_1 = Dense(self.hidden_dim, activation='relu')(self.input_bow)
  File "/home/admin1/3/SourceCodeAnalytics-master/src/utils.py", line 73, in __call__
    self.build(shape)
  File "/home/admin1/3/SourceCodeAnalytics-master/src/utils.py", line 61, in build
    self.W = tf.Variable(xavier_init(input_dim, self.output_dim))
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variables.py", line 183, in __call__
    return cls._variable_v1_call(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variables.py", line 146, in _variable_v1_call
    aggregation=aggregation)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variables.py", line 125, in <lambda>
    previous_getter = lambda **kwargs: default_variable_creator(None, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variable_scope.py", line 2444, in default_variable_creator
    expected_shape=expected_shape, import_scope=import_scope)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variables.py", line 187, in __call__
    return super(VariableMetaclass, cls).__call__(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variables.py", line 1329, in __init__
    constraint=constraint)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variables.py", line 1491, in _init_from_args
    self._snapshot = array_ops.identity(self._variable, name="read")
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/array_ops.py", line 81, in identity
    return gen_array_ops.identity(input, name=name)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 3454, in identity
    "Identity", input=input, name=name)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/deprecation.py", line 488, in new_func
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 3274, in create_op
    op_def=op_def)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 1770, in __init__
    self._traceback = tf_stack.extract_stack()

FailedPreconditionError (see above for traceback): Attempting to use uninitialized value Variable_9
	 [[node Variable_9/read (defined at /home/admin1/3/SourceCodeAnalytics-master/src/vdsh_utils.py:61)  = Identity[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](Variable_9)]]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions