2

I am using windows GPU tensorflow 1.0. I want to delete useless or wrong tf variable.

For example I run code and generate a bad model, then I copy code and just modify existed variable W1(shape=[3,3],name="W1") as W1(shape=[5,5],name="W1") and run.  

 However tensorflow generate W1(shape=[5,5],name="W1_1") rather than replace old W1. So in the end Tensorflow will save both wrong trained W1(name='w1') and trained w1(name='w1_1'). When I restore W1, tensorflow give me wrong trained W1(name='w1').    

Could you tell me how to delete old variable W1 and add new W1?

(the newline edit function is useless)

Suhaib Janjua
  • 3,538
  • 16
  • 59
  • 73
artzers
  • 101
  • 1
  • 2
  • 5
  • reformulate in a cleaner way. I don’t understand what you mean. provide some code that reproduces the problem. – fabrizioM Feb 22 '17 at 07:45

1 Answers1

0

First of all, I don't know exactly what you are trying to achieve by changing the shape of your variable. If you would have asked the question in such a way we knew your intent, maybe we could help you better.

Now there are multiple options to solve your problem: - ignore the name of your variable (what bugs does it cause??) - remove all variables: https://www.tensorflow.org/versions/master/api_docs/python/framework/utility_functions#reset_default_graph - Change the shape of the variable instead of defining a new one. Check the answer of mrry here: How can I change the shape of a variable in TensorFlow?

rmeertens
  • 4,383
  • 3
  • 17
  • 42
  • I rewrite my question. In a word, I want to handle every variable precisely. It seems there is no way to modify the existed variables. Maybe I have to clear all variable and restart. Your answer is helpful. – artzers Feb 23 '17 at 08:24
  • Thanks! Good luck! – rmeertens Feb 23 '17 at 08:42