Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ch02 concept 6 Saving variable #20

Open
boloson opened this issue Jul 30, 2017 · 6 comments
Open

Ch02 concept 6 Saving variable #20

boloson opened this issue Jul 30, 2017 · 6 comments

Comments

@boloson
Copy link

boloson commented Jul 30, 2017

saver.save(sess, "spikes.ckpt") doesn't work

require running tf.global_variables_initializer() for newer version of Tensorflow

sess = tf.InteractiveSession()
init = tf.global_variables_initializer()
sess.run(init)

raw_data = [1., 2., 8., -1., 0., 5.5, 6., 13]
spikes = tf.Variable([False] * len(raw_data), name='spikes')
spikes.initializer.run()

saver = tf.train.Saver()

@sirusss
Copy link

sirusss commented Nov 5, 2017

Same issue (Not found: ; No such file or directory). Apparently, it tries to look for the file before creating it.

@roip
Copy link

roip commented Dec 2, 2017

running on a windows machine, change line : saver.save(sess, "spikes.ckpt")
to saver.save(sess, "./spikes.ckpt") resulted in successful save of the checkpoint

@sansmoraxz
Copy link

saver.save(sess, "spikes.ckpt")

This line raises the error:
ValueError: Parent directory of spikes.ckpt doesn't exist, can't save.

It's pretty clear the parameter is asking for a path and not just a file name. So please fix the code into the format as @roip suggested or into a sub-directory format like this:
saver.save(sess, "train_saves\spikes.ckpt")

@nickdesaulniers
Copy link

I had to use "./spikes.ckpt"

@tangyong
Copy link

tangyong commented Apr 8, 2018

except for "Parent directory of spikes.ckpt doesn't exist", on windows and spyder, the following error happened:

...
shape_and_slices=shape_and_slices, tensors=tensors, name=name)
File "e:\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "e:\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 3290, in create_op
op_def=op_def)
File "e:\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 1654, in init
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

FailedPreconditionError (see above for traceback): Attempting to use uninitialized value Variable
[[Node: save_7/SaveV2 = SaveV2[dtypes=[DT_BOOL, DT_BOOL, DT_BOOL, DT_BOOL, DT_BOOL, DT_BOOL, DT_BOOL, DT_BOOL, DT_BOOL, DT_BOOL, DT_BOOL, DT_BOOL, DT_BOOL, DT_BOOL], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save_7/Const_0_0, save_7/SaveV2/tensor_names, save_7/SaveV2/shape_and_slices, Variable, Variable_1, Variable_2, Variable_3, Variable_4, spikes, spikes_1, spikes_2, spikes_3, spikes_4, spikes_5, spikes_6, spikes_7, spikes_8)]]
...

I also doubt this is the spyder's problem because it works on python console.

@tangyong
Copy link

tangyong commented Apr 8, 2018

adding the following in spyder has fixed the problem! (including any file eg. loading variable)

tf.reset_default_graph()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants