1

Is it possible to switch between keras backend in same python program in which both backend specific functions are imported from the keras internal (tensorflow_backend.py, theano_backend.py and cntk_backend.py).

When I set os.environ[KERAS_BACKEND]='theano' I get errors from Keras tensorflow internal.

I need to get output from keras tensorflow and keras theano internal (from backend file)for same calculation in same program

EndangeredMassa
  • 17,208
  • 8
  • 55
  • 79
n_001
  • 13
  • 2

1 Answers1

0

My guess would be no. Keras is bound to only one session and switching the backend midway in program seems like no good idea at all. If you are trying to compare specific function from the backend why not just load the backend frameworks directly and then run the code?

It sounds like you want to do a benchmarking from keras with different backends but keras is just an API so you can easily test the frameworks without it and return to it later, when you know which backend is better for you.

If you still try to do this: Would multiprocessing be a solution? You could import keras with tensorflow and keras with theano inside different processes.

dennis-w
  • 2,166
  • 1
  • 13
  • 23