The choice of the first deep learning framework has always been a headache for beginners. In this article, researchers from DeepSense. ai give their answer on a high-level framework. In the comparison between Keras and PyTorch, the authors also provide benchmark results for the performance of the same neural network in different frameworks. Keras currently has more than 31,000 Stars on GitHub, while PyTorch, which debuted later, has nearly 17,000 Stars. Links to two major frameworks: Keras: github.com/keras-team/... PyTorch:github.com/pytorch/pyt... Keras and PyTorch are open source frameworks for deep learning that are popular with data scientists. Keras is a high-level API that can run on TensorFlow, CNTK, Theano, or MXNet (or as tF.contrib within TensorFlow). Keras was first released in March 2015 and has since grown rapidly with support for its ease of use and simplicity of syntax. Keras is a Framework supported by Google. PyTorch was released in January 2017 as a lower-level API focused on working directly with array expressions. It received a lot of attention last year as a solution for academic research and deep learning application preferences that need to optimize custom expressions. It's a framework supported by Facebook. Before we get into the specifics of both, we want to make it clear that there is no straightforward answer to the question of "which framework is better?" Which framework you choose ultimately depends on your technical background, needs, and expectations. This article is intended to help you better understand when you should choose Keras or PyTorch. In a word, Keras is easier to learn and experiment with the standard layer, plug and play; PyTorch provides a lower-level approach that is more flexible for users with a more mathematical background. So why not use another framework? This article does not discuss the pros and cons of choosing TensorFlow as the preferred deep learning framework, as we consider TensorFlow to be less novice friendly than Keras (TensorFlow's official high-level library) and PyTorch. Theano is no longer in active development, although you can find some tutorials on it. Caffe lacks flexibility, and Torch uses Lua (which is difficult to rewrite, however :)). MXNet, Chainer, and CNTK are currently less widely used. Keras vs PyTorch: Ease of Use and Flexibility Keras and PyTorch have different levels of operational abstraction. Keras is a higher-level framework that encapsulates commonly used deep learning layers and operations into clean, Lego-sized building blocks, freeing data scientists from the complexity of deep learning. PyTorch provides a relatively low-level experimental environment that gives users more freedom to write custom layers and view numerical optimization tasks. The development of complex architectures is much more straightforward when you can use the full power of Python and access the core of all the functions you use. This naturally comes at the cost of verbosity. A simple convolutional network defined in Keras and PyTorch is used to compare the two:  Keras model = Sequential() model.add(Conv2D(32, (3, 3), activation='relu', input_shape=(32, 32, 3))) model.add(MaxPool2D()) model.add(Conv2D(16, (3, 3), activation='relu')) model.add(MaxPool2D()) model.add(Flatten()) model.add(Dense(10, activation='softmax')) PyTorch class Net(nn.Module): def __init__(self): super(Net, self).__init__() self.conv1 = nn.Conv2d(3, 32, 3) self.conv2 = nn.Conv2d(32, 16, 3) self.fc1 = nn.Linear(16 * 6 * 6, 10) self.pool = nn.MaxPool2d(2, 2) def forward(self, x): x = self.pool(F.relu(self.conv1(x))) x = self.pool(F.relu(self.conv2(x))) x = x.view(-1, 16 * 6 * 6) x = f.log_softmax (self.fc1(x), dim=-1) return x model = Net() The code snippet above shows the slight differences between the two frameworks. As for model training, it takes about 20 lines of code in PyTorch and only one line in Keras. GPU acceleration can be handled implicitly in Keras, whereas PyTorch requires us to specify when to migrate data between the CPU and GPU. If you're new, Keras may have a significant advantage as a higher-level framework. Keras is definitely more readable and concise, allowing users to skip some implementation details and build their first end-to-end deep learning model more quickly. However, ignoring these details limits the user's opportunity to explore the inner workings of each computing module in the deep learning process. Using PyTorch will provide more opportunities to think more deeply about core concepts of deep learning such as back propagation and other training processes. That said, Keras, while much simpler than PyTorch, is far from a "toy," it's a serious deep learning tool for beginners and experienced data scientists alike. For example, in the DSTL Satellite Image Feature Detection Kaggle competition, the top 3 teams' solutions all used Keras, and the fourth place team (DeepSense.ai) used PyTorch and Keras. It's worth considering whether your deep learning application needs more flexibility than Keras can provide. Depending on your needs, following the Rule of least Power, Keras may be the perfect solution. Conclusion Keras: Leaner, simpler API PyTorch: More flexible and encourages a deeper understanding of deep learning conceptsCopy the code