printing keras backend eval crashes the kernel

0

I try to implement a keras backend function f, to be used in a custom loss function. When I compute f(x, y) or even K.eval(f(x, y)) it is fine, yet printing K.eval(f(x, y)) crashes the kernel.

Pycharm writes

Process finished with exit code -1073741819 (0xC0000005)

Jupyter notebook outputs

"The kernel crashed, it will restart automatically".

Runing this in a terminal also crashes python.

I've tried uninstalling and reinstalling keras. I have python 3.6, keras 2.2.4, tensorflow 1.13.1, and numpy 1.15.2. OS is windows 10.

A minimal example :

from keras import backend as K
import numpy as np    

def f(x, y):
    return x + y

b = K.constant(np.array([1, 0, 0, 0]))
c = K.constant(np.array([0, 1, 0, 1]))
# this works if you comment the rest out :
evaluation = K.eval(f(b, c))
# this KILLS the freaking KERNEL !!!
print(evaluation)

A solution (?)

I updated numpy to 1.16.3 and it seems to work again.

python
keras
asked on Stack Overflow Apr 26, 2019 by Olivier Roche • edited Apr 29, 2019 by Olivier Roche

1 Answer

0

It could come from your tensorflow version. I tried your code with the same versions except for the Tensorflow version which is 1.10 (instead of 1.13.1) and it works.

answered on Stack Overflow Apr 26, 2019 by Etienne Landuré

User contributions licensed under CC BY-SA 3.0