Skip to content

Commit

Permalink
correctly init the keras backend in the unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasMahieu committed Dec 2, 2024
1 parent edab6dd commit 61c080a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
"""Init file for the tests module."""

import os

# Set keras backend
try:
import tensorflow as tf

os.environ["KERAS_BACKEND"] = "tensorflow"
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
except ImportError:
try:
import torch

os.environ["KERAS_BACKEND"] = "torch"
except ImportError as e:
raise ImportError(
"No backend found. Please install either tensorflow or pytorch."
) from e

0 comments on commit 61c080a

Please sign in to comment.