Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences in SciKit Learn, Keras, or Pytorch [closed]

Are these libraries fairly interchangeable?

Looking here, https://stackshare.io/stackups/keras-vs-pytorch-vs-scikit-learn, it seems the major difference is the underlying framework (at least for PyTorch).

like image 390
MaxPi Avatar asked Feb 05 '19 03:02

MaxPi


People also ask

What is the difference between scikit-learn and Keras?

Scikit-learn doesn't have native support for GPU computing and deep learning. Consider Keras if your application/model has to use neural networks to learn from large amounts of data. Keras also caters for those who are fairly new to deep learning.

What is the difference between PyTorch and Keras?

PyTorch vs Keras Keras is better suited for developers who want a plug-and-play framework that lets them build, train, and evaluate their models quickly. Keras also offers more deployment options and easier model export. However, remember that PyTorch is faster than Keras and has better debugging capabilities.

Which is better sklearn or Keras?

If you want to predict people's opinion in movie reviews, then a deep learning approach using Keras or PyTorch makes sense, and if you want to predict the price of future NBA game tickets, then scikit-learn's ability to crunch structured data is all you need.

Is Keras faster than sklearn?

Sklearn takes 0.01s to train the model and achieves 97% accuracy, but Keras (TensorFlow backend) takes 10s to achieve same accuracy after 50 epoches (even one epoch is 20x slower than sklearn).


1 Answers

Yes, there is a major difference.

SciKit Learn is a general machine learning library, built on top of NumPy. It features a lot of machine learning algorithms such as support vector machines, random forests, as well as a lot of utilities for general pre- and postprocessing of data. It is not a neural network framework.

PyTorch is a deep learning framework, consisting of

  1. A vectorized math library similar to NumPy, but with GPU support and a lot of neural network related operations (such as softmax or various kinds of activations)
  2. Autograd - an algorithm which can automatically calculate gradients of your functions, defined in terms of the basic operations
  3. Gradient-based optimization routines for large scale optimization, dedicated to neural network optimization
  4. Neural-network related utility functions

Keras is a higher-level deep learning framework, which abstracts many details away, making code simpler and more concise than in PyTorch or TensorFlow, at the cost of limited hackability. It abstracts away the computation backend, which can be TensorFlow, Theano or CNTK. It does not support a PyTorch backend, but that's not something unfathomable - you can consider it a simplified and streamlined subset of the above.

In short, if you are going with "classic", non-neural algorithms, neither PyTorch nor Keras will be useful for you. If you're doing deep learning, scikit-learn may still be useful for its utility part; aside from it you will need the actual deep learning framework, where you can choose between Keras and PyTorch but you're unlikely to use both at the same time. This is very subjective, but in my view, if you're working on a novel algorithm, you're more likely to go with PyTorch (or TensorFlow or some other lower-level framework) for flexibility. If you're adapting a known and tested algorithm to a new problem setting, you may want to go with Keras for its greater simplicity and lower entry level.

like image 76
Jatentaki Avatar answered Oct 17 '22 13:10

Jatentaki