Equivalent of keras backend floatx in pytoch

I am converting a keras code to pytorch and want to convert this

import keras.backend as K
train_y = np.array(train_y, dtype=K.floatx())

I am trying to find a way to include the CUDA float variable but couldn’t. Any help is appreciated

Assuming train_y is a numpy array of type float, this should do what you want

train_y = Torch.tensor(train_y).cuda()

If you need to force train_y to be of type float you can do this

train_y = Torch.tensor(train_y).float().cuda()

I’d probably just use np.float32 if you are using FloatTensor.

Best regards

Thomas