Search code examples
python-3.xmachine-learningconfigtflearn

Multiple TFLearn Models in One Python Script


I am running sequentially several Neural Net models in a single python3 script as follows:

neural_net_model = tflearn.DNN(network, checkpoint_path=XYZ, 
                    tensorboard_dir=DIR), tensorboard_verbose=2, max_checkpoints=1)

The first model runs fine. When I instantiate the second model I invariably get this error.

InvalidArgumentError: Shape [-1,224,224,1] has negative dimensions

224x224 are the dimensions of the images I am processing

If I restart the kernel, the model runs fine

Is it possible to explicitly close or clear the first model so the new model will run without a hitch?

I am running in an Anaconda environment


Solution

  • The following code will reset the graph and allow the script to run a new model

    tf.reset_default_graph()