<p dir="auto"><em>Please make sure that this is a bug. As per our <a href="https://github.com/tensorflow/tensorflow/blob/master/ISSUES.md">GitHub Policy</a>, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template</em></p>
<p dir="auto"><strong>System information</strong></p>
<ul dir="auto">
<li>Have I written custom code (as opposed to using a stock example script provided in TensorFlow): yes</li>
<li>OS Platform and Distribution (e.g., Linux Ubuntu 16.04): mac</li>
<li>Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: none</li>
<li>TensorFlow installed from (source or binary): binary</li>
<li>TensorFlow version (use command below): 2.0.alpha0</li>
<li>Python version:</li>
<li>Bazel version (if compiling from source): none</li>
<li>GCC/Compiler version (if compiling from source): none</li>
<li>CUDA/cuDNN version: none</li>
<li>GPU model and memory: none</li>
</ul>
<p dir="auto">You can collect some of this information using our environment capture<br>
<a href="https://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh">script</a><br>
You can also obtain the TensorFlow version with: 1. TF 1.0: <code class="notranslate">python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"</code> 2. TF 2.0: <code class="notranslate">python -c "import tensorflow as tf; print(tf.version.GIT_VERSION, tf.version.VERSION)"</code></p>
<p dir="auto"><strong>Describe the current behavior</strong><br>
It works fine when run this in one console</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import tensorflow as tf
import numpy as np


m = tf.Module()
m.v = tf.Variable(np.random.normal(size=(200, 200)).astype(np.float64))
m.f = tf.function(lambda x: x + m.v[0, 0])

tf.saved_model.save(m, &quot;save/model&quot;, signatures={
    &quot;predict&quot;: m.f.get_concrete_function(tf.constant(3., dtype=tf.float64))
})"><pre class="notranslate"><code class="notranslate">import tensorflow as tf
import numpy as np


m = tf.Module()
m.v = tf.Variable(np.random.normal(size=(200, 200)).astype(np.float64))
m.f = tf.function(lambda x: x + m.v[0, 0])

tf.saved_model.save(m, "save/model", signatures={
    "predict": m.f.get_concrete_function(tf.constant(3., dtype=tf.float64))
})
</code></pre></div>
<p dir="auto">and then the other</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import tensorflow as tf
m = tf.saved_model.load(&quot;save/model&quot;)"><pre class="notranslate"><code class="notranslate">import tensorflow as tf
m = tf.saved_model.load("save/model")
</code></pre></div>
<p dir="auto">If you change 200 to 20000, you will see errors on load</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import tensorflow as tf
import numpy as np


m = tf.Module()
m.v = tf.Variable(np.random.normal(size=(20000, 20000)).astype(np.float64))
m.f = tf.function(lambda x: x + m.v[0, 0])

tf.saved_model.save(m, &quot;save/model&quot;, signatures={
    &quot;predict&quot;: m.f.get_concrete_function(tf.constant(3., dtype=tf.float64))
})"><pre class="notranslate"><code class="notranslate">import tensorflow as tf
import numpy as np


m = tf.Module()
m.v = tf.Variable(np.random.normal(size=(20000, 20000)).astype(np.float64))
m.f = tf.function(lambda x: x + m.v[0, 0])

tf.saved_model.save(m, "save/model", signatures={
    "predict": m.f.get_concrete_function(tf.constant(3., dtype=tf.float64))
})
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import tensorflow as tf
tf.saved_model.load(&quot;save/model&quot;)
# tensorflow.python.framework.errors_impl.InvalidArgumentError: save/model/variables/variables.data-00000-of-00001; Invalid argument [Op:RestoreV2]"><pre class="notranslate"><code class="notranslate">import tensorflow as tf
tf.saved_model.load("save/model")
# tensorflow.python.framework.errors_impl.InvalidArgumentError: save/model/variables/variables.data-00000-of-00001; Invalid argument [Op:RestoreV2]
</code></pre></div>
<p dir="auto"><strong>Describe the expected behavior</strong></p>
<p dir="auto">Should be able to load regardless of the size of variable</p>
<p dir="auto"><strong>Code to reproduce the issue</strong><br>
Provide a reproducible test case that is the bare minimum necessary to generate the problem.<br>
see above<br>
<strong>Other info / logs</strong><br>
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.</p>
<p dir="auto">I get an InvalidArgumentError with no further information when I try to save and then restore parts of my model later to continue training it (due to needing my laptop for class).</p>
<p dir="auto">Initialization:<br>
saver = tf.train.Saver({"embeddings": embeddings, "weights": nce_weights, "biases": nce_biases})</p>
<p dir="auto">Save:<br>
saver.save(sess, model_checkpoint_path)</p>
<p dir="auto">Load:<br>
saver.restore(sess, model_checkpoint_path)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="2018-04-21 22:45:00.143245: W tensorflow/core/framework/op_kernel.cc:1273] OP_REQUIRES failed at save_restore_v2_ops.cc:184 : Invalid argument: /Users/nroth/Documents/****/trained_model/****embeddings.ckpt.data-00000-of-00001; Invalid argument
Traceback (most recent call last):
  File &quot;/Users/nroth/tf_python/lib/python3.6/site-packages/tensorflow/python/client/session.py&quot;, line 1327, in _do_call
    return fn(*args)
  File &quot;/Users/nroth/tf_python/lib/python3.6/site-packages/tensorflow/python/client/session.py&quot;, line 1312, in _run_fn
    options, feed_dict, fetch_list, target_list, run_metadata)
  File &quot;/Users/nroth/tf_python/lib/python3.6/site-packages/tensorflow/python/client/session.py&quot;, line 1420, in _call_tf_sessionrun
    status, run_metadata)
  File &quot;/Users/nroth/tf_python/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py&quot;, line 516, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: /Users/nroth/Documents/****/trained_model/****embeddings.ckpt.data-00000-of-00001; Invalid argument
	 [[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT], _device=&quot;/job:localhost/replica:0/task:0/device:CPU:0&quot;](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]

... &lt;contains sensitive info&gt; ...

InvalidArgumentError (see above for traceback): /Users/nroth/Documents/****/trained_model/****embeddings.ckpt.data-00000-of-00001; Invalid argument
	 [[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT], _device=&quot;/job:localhost/replica:0/task:0/device:CPU:0&quot;](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]"><pre class="notranslate"><code class="notranslate">2018-04-21 22:45:00.143245: W tensorflow/core/framework/op_kernel.cc:1273] OP_REQUIRES failed at save_restore_v2_ops.cc:184 : Invalid argument: /Users/nroth/Documents/****/trained_model/****embeddings.ckpt.data-00000-of-00001; Invalid argument
Traceback (most recent call last):
  File "/Users/nroth/tf_python/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1327, in _do_call
    return fn(*args)
  File "/Users/nroth/tf_python/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1312, in _run_fn
    options, feed_dict, fetch_list, target_list, run_metadata)
  File "/Users/nroth/tf_python/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1420, in _call_tf_sessionrun
    status, run_metadata)
  File "/Users/nroth/tf_python/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 516, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: /Users/nroth/Documents/****/trained_model/****embeddings.ckpt.data-00000-of-00001; Invalid argument
	 [[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]

... &lt;contains sensitive info&gt; ...

InvalidArgumentError (see above for traceback): /Users/nroth/Documents/****/trained_model/****embeddings.ckpt.data-00000-of-00001; Invalid argument
	 [[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]
</code></pre></div>
<p dir="auto"><strong>Clarification requested by tensorflowbutler</strong><br>
<em>Have I written custom code:</em><br>
Yes, I modified this code (<a href="https://github.com/PacktPublishing/TensorFlow-Machine-Learning-Cookbook/blob/master/Chapter%2007/doc2vec.py">https://github.com/PacktPublishing/TensorFlow-Machine-Learning-Cookbook/blob/master/Chapter%2007/doc2vec.py</a>) to work with TensorFlow 1.7 and to use the same embeddings variable for documents as for words with average instead of concatenation. I also updated the saved variables to include nce_weights and nce_biases so that training may be resumed.<br>
<em>OS Platform and Distribution</em><br>
MacOS 10.13.4 (17E199)<br>
<em>TensorFlow installed from</em><br>
pip on VirtualEnv, according to instructions (<a href="https://www.tensorflow.org/install/install_mac" rel="nofollow">https://www.tensorflow.org/install/install_mac</a>)<br>
<em>TensorFlow version</em><br>
1.7<br>
<em>Bazel version</em><br>
NA<br>
<em>CUDA/cuDNN version</em><br>
NA<br>
<em>GPU model and memory</em><br>
NA<br>
<em>Exact command to reproduce</em><br>
saver = tf.train.Saver({"embeddings": embeddings, "weights": nce_weights, "biases": nce_biases})<br>
saver.restore(sess, "../trained_model/saved_stuff")</p>