torch backend apis note on device placement torch has a different device placement style compared to tf and jax in short variablestensors are not created on gpu by default and the gpu cannot directly communicate with the cpu to bring torch behavior in line with tf and jax automated device placement we are doing the following to automate device placement if a gpu is available variables are created on gpu input data will be placed on gpu at the first keras layers layer call tensor creation happens on gpu e g zeros will create a tensor on gpu converttonumpy will bring the tensor to cpu before converting it to numpy
from keras.backend.torch import core
from keras.backend.torch import image
from keras.backend.torch import math
from keras.backend.torch import nn
from keras.backend.torch import numpy
from keras.backend.torch import random
from keras.backend.torch.core import SUPPORTS_SPARSE_TENSORS
from keras.backend.torch.core import Variable
from keras.backend.torch.core import cast
from keras.backend.torch.core import compute_output_spec
from keras.backend.torch.core import cond
from keras.backend.torch.core import convert_to_numpy
from keras.backend.torch.core import convert_to_tensor
from keras.backend.torch.core import device_scope
from keras.backend.torch.core import is_tensor
from keras.backend.torch.core import scatter
from keras.backend.torch.core import shape
from keras.backend.torch.core import stop_gradient
from keras.backend.torch.core import to_torch_dtype
from keras.backend.torch.core import vectorized_map
from keras.backend.torch.rnn import cudnn_ok
from keras.backend.torch.rnn import gru
from keras.backend.torch.rnn import lstm
from keras.backend.torch.rnn import rnn