What is the Pytorch Equivalent of Keras 'K' and 'lambda?

I want to know is there any function for
K.ctc_batch_cost() for Pytorch.
and also for
ctc_loss = Lambda(ctc_lambda_func, output_shape=(1,), name=‘ctc’)([y_pred, labels, input_length, label_length])
In this code, ctc_lambda_func is a function I earlier defined. And y_pred,… are parameteres I have defined. I want the equivalent of lambda.
Thanks !!

I guess nn.CTCLoss might be the equivalent to ctc_batch_loss.
What does the Lambda function do? It seems you are passing a ctc_lambda_func to it and execute it with input data?

Note that you don’t have to define the computation graph beforehand in PyTorch and can just execute the code similar to numpy.
E.g. you can define modules and pass the tensors directly to them. Have a look at the tutorial section for an introduction. :wink:

1 Like

Great, thanks for explaining !! It does explain itself. I am a beginner, do you think I should also learn keras for future or only the docs are fine

I’m not sure, if I misunderstand the question, but if you want to learn PyTorch, the docs and tutorials should be fine. There is no need to learn Keras in order to work with PyTorch. On the other hand, if you would like to learn Keras, I would recommend to look into their tutorial section. :wink:

1 Like