AttributeError: ‘Tensor‘ object has no attribute ‘_numpy‘

Problem Description:

In TF2. X environment, the user-defined loss function error, want to view y_ PRED and Y_ True, using K. Eval (y)_ pred),y_ Pred.numpy() error:
attributeerror: ‘tense’ object has no attribute ‘_ numpy’

resolvent:

Set run in model. Compile()_ When eagerly is changed to true, you can view it, but the running speed will be slow

Analysis of the reasons:

run_ Eagerly parameter setting model is to create dynamic graph or static graph (default is static graph, false)
running eagerly means that your model will run step by step, just like Python code. Dynamic graph mechanism may make the model run slowly, because it can’t use the optimization method of static graph in previous versions; But its advantage is that it is easy for you to debug
by default, we will compile your model and make it a static graph to get the best performance
reference blog
in TF2. X, by default, every tenor has numpy, but there is no GitHub problem description in keras


Read More: