Moving from Keras to Pytorch

Why? How? It's not that difficult.

Rahul Agarwal
Towards Data Science
7 min readMay 28, 2019

Photo by David Clode on Unsplash

Pytorch is great. But it doesn’t make things easy for a beginner.

A while back, I was working with a competition on Kaggle on text classification, and as a part of the competition, I had to somehow move to Pytorch to get deterministic results. Results that don’t change with every run of the network to try out different models and have consistent results.

Now I have always worked with Keras in the past and it has given me pretty good results, but somehow I got to know that the CuDNNGRU/CuDNNLSTM layers in keras are not deterministic, even after setting the seeds.

So Pytorch did come to rescue. And I am glad that I considered moving.

As a side note: if you want to know more about NLP, I would like to recommend this awesome course on Sequence modelling in the Deep Learning Specialization. This course covers a wide range of tasks in Natural Language Processing from basic to advanced: Sentiment Analysis, summarization, dialogue state tracking, to name a few.

While Keras is great to start with deep learning, with time you are going to resent some of its limitations.

I also thought about moving to Tensorflow. It seemed like a good transition as TF is the backend of Keras.

Published in Towards Data Science

Your home for data science and AI. The world’s leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.

Responses (6)

What are your thoughts?