I really hate this whole book being so outdated, but still.
Does anyone know what should I do with gradient tensor normalization?
The code in the book (and in the notebook here) goes as follows:
grads /= (K.sqrt(K.mean(K.square(grads))) + 1e-5)
and once I copy it into my notebook I get this:
ValueError: Tensor("Const_2:0", shape=(4,), dtype=int32) must be from the same graph as Tensor("Square_2:0", shape=(None, None, None, 3), dtype=float32) (graphs are <tensorflow.python.framework.ops.Graph object at 0x7f3a0d868550> and FuncGraph(name=keras_graph, id=139887061480000)).
Google doesn't really have anything useful to offer.
SOLVED
Rearranging imports helps.
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import backend as K
from tensorflow.keras.applications import VGG16
I really hate this whole book being so outdated, but still. Does anyone know what should I do with gradient tensor normalization? The code in the book (and in the notebook here) goes as follows:
grads /= (K.sqrt(K.mean(K.square(grads))) + 1e-5)
and once I copy it into my notebook I get this:
ValueError: Tensor("Const_2:0", shape=(4,), dtype=int32) must be from the same graph as Tensor("Square_2:0", shape=(None, None, None, 3), dtype=float32) (graphs are <tensorflow.python.framework.ops.Graph object at 0x7f3a0d868550> and FuncGraph(name=keras_graph, id=139887061480000)).
Google doesn't really have anything useful to offer.
SOLVED
Rearranging imports helps.