0

So I've been changing a code of someone else to make my computer deep dream because it didn't work, I already solved a couple errors but I'm not able to fix this one. Thanks in advance.

THIS IS THE ORIGINAL GITHUB PROJECT https://github.com/cysmith/neural-style-tf

THIS IS THE ERROR I GET

  File "E:\anaconda\neural-style-tf-master\neural_style.py", line 362, in style_layer_loss
    M = h.value * w.value
AttributeError: 'int' object has no attribute 'value'

THIS IS THE CODE AROUND LINE 362

def style_layer_loss(a, x):
  _, h, w, d = a.get_shape()
  M = h.value * w.value
  N = d.value
  A = gram_matrix(a, M, N)
  G = gram_matrix(x, M, N)
  loss = (1./(4 * N**2 * M**2)) * tf.reduce_sum(tf.pow((G - A), 2))
  return loss

THIS IS MY PARTIALLY REPROGRAMMED VERSION OF neural_style.py

https://github.com/nicolai256/ERROR/blob/master/neural_style.py

desertnaut
  • 57,590
  • 26
  • 140
  • 166
  • Instead of `value` try `values`. Let me know if that doesn't work and I'll try something else. – zerecees Jul 28 '20 at 01:15
  • if ```h``` or ```w``` are ints, then you need to use their values by just using the variable name without the ```.value``` part. That said, I'm not entirely convinced that is the solution since without knowing what get_shape() is returning, it's hard to judge if just removing ```.value``` is the right solution. – ewokx Jul 28 '20 at 01:20
  • I changed all the '''value''' codes into '''values''' but I still get the same error – Nicolai Vernieuwe Jul 28 '20 at 01:23
  • I deleted all the .value parts and I don't get the same error anymore but I get another error now... File "E:\anaconda\neural-style-tf-master\neural_style.py", line 624, in get_optimizer optimizer = tf.contrib.opt.ScipyOptimizerInterface( AttributeError: module 'tensorflow' has no attribute 'contrib'. – Nicolai Vernieuwe Jul 28 '20 at 01:27
  • It sounds like you’re trying to run a script for Tensorflow 1.x using Tensorflow 2.0. See here https://stackoverflow.com/questions/55870127/module-tensorflow-has-no-attribute-contrib – Joe Jul 28 '20 at 01:31
  • so if i downgrade my tensorflow to 1.x the script should run fine? – Nicolai Vernieuwe Jul 28 '20 at 01:49
  • Please avoid block capitals (let alone in **bold**)... – desertnaut Jul 29 '20 at 16:19

0 Answers0