nfmcclure / tensorflow_cookbook

Code for Tensorflow Machine Learning Cookbook
https://www.packtpub.com/big-data-and-business-intelligence/tensorflow-machine-learning-cookbook-second-edition
MIT License
6.23k stars 2.41k forks source link

05_Stylenet_NeuralStyle problem #115

Closed atushi0624 closed 6 years ago

atushi0624 commented 6 years ago

The following error message occurs in 05_stylenet_neuralstyle: How do I fix it?

error message: RuntimeError Traceback (most recent call last)

in () 7 original_minus_mean = original_image - normalization_mean 8 original_norm = np.array([original_minus_mean]) ----> 9 original_features[original_layer] = sess.run(vgg_net[original_layer], feed_dict={image: original_norm}) . . . RuntimeError: The Session graph is empty. Add operations to the graph before calling run(). I fixed the following in tf.Session, but the result was the same. g = tf.Graph() sess = tf.Session(graph=g)
nfmcclure commented 6 years ago

Thanks for the notice. I found the same bug earlier and couldn't find a quick fix. I do remember there being a pull request that someone made that addressed this issue. I'm working on a v2 of all the code over the next few months and will update accordingly. Thanks.

nfmcclure commented 6 years ago

I have revamped the style net. I couldn't get mine to work at all.

Instead, I have adapted the method from here: https://github.com/anishathalye/neural-style . The way the feed-forward features and loss is calculated is much better.

The link above also has better smoothing and styling. I recommend using the linked version. The fixed version is a bit basic at the moment and really touchy on paramters.