4
$\begingroup$

I am looking into implementing a convolutional neural network for a research problem. I've heard of deep learning libraries like Pytorch and Tensorflow and was hoping to get some additional information about their suitability for my needs.

I haven't looked much into Pytorch, and have only briefly read about Tensorflow. I don't hear very nice things about Tensorflow in terms of ease of use. I hear Pytorch is easier to use. But there seems to be more tutorials for Tensorflow, and specifically for creating CNNs.

What sort of questions should I be asking myself in determining which library would best suit my needs?

$\endgroup$
2
  • 2
    $\begingroup$ You shouldn't ask an opinion-based question here. Regarding the second question, would you go to production with your code or is it only for research, would you use only deep learning or some other techniques? Anyway, both libraries you mentioned are good. ;) $\endgroup$
    – wind
    Dec 19, 2018 at 7:28
  • $\begingroup$ Sorry about that. Perhaps I can rephrase my question. It's for my PhD research, but if it turns out nicely, it may be integrated as a design tool at a governmental lab. $\endgroup$
    – anonuser01
    Dec 19, 2018 at 15:14

2 Answers 2

5
$\begingroup$

If you are looking for something easy to use and to read, definitely go for Keras.


Example of CNN in Keras :

model = Sequential()
model.add(Conv2D(32, kernel_size=(3, 3),
                 activation='relu',
                 input_shape=input_shape))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(num_classes, activation='softmax'))

model.compile(loss=keras.losses.categorical_crossentropy,
              optimizer=keras.optimizers.Adadelta(),
metrics=['accuracy']) 

So easy to read !

Source, literally the first link when searching for "keras CNN" on Google.


I really enjoy Keras, because it's easy to read, easy to use, great documentation, and if you want to mess up things at lower level you can do it by touching the back-end of Keras (Tensorflow or Theano)

EDIT (following your comment)

Excellent blog : Keras vs Tensorflow

$\endgroup$
5
  • $\begingroup$ I've looked a little bit into Keras. Basically, what I got from my readings is Keras is much more high-level, relatively easier to use, but may be limited for some problems. Unfortunately, I don't have any experience with this to know if Keras has all the capability I'd need for my research problem. If, say you're building a CNN with Keras, and you find out there's something you need that can't be done with Keras. Would you have to start over in Tensorflow, or could you somehow port over what you need from Tensorflow over to Keras? $\endgroup$
    – anonuser01
    Dec 19, 2018 at 15:18
  • 2
    $\begingroup$ You can utilize everything in Tensorflow from within Keras. Sometimes it may require writing your own layers but it is always possible $\endgroup$
    – kbrose
    Dec 19, 2018 at 19:01
  • $\begingroup$ Keras is based on Tensorflow (or Theano). Which means that virtually anything you can do with Tensorflow, you can do it with Keras. I was also afraid to meet the problem you described when I started Keras (not being able to do something and having to learn another framework). But since I'm working with Keras, I never met this problem. Sure sometimes what I want to do is not in Keras itself, but then I can quickly build a solution using Tensorflow (working with tensors) and make it into Keras. Did I mention that Keras was so easily readable ? $\endgroup$
    – Astariul
    Dec 20, 2018 at 0:14
  • $\begingroup$ @Astariul Have you also tried Pytorch? $\endgroup$
    – anonuser01
    Dec 27, 2018 at 22:46
  • $\begingroup$ I didn't tried it myself, but I've tried to read some code in Pytorch. $\endgroup$
    – Astariul
    Dec 27, 2018 at 23:26
1
$\begingroup$

Personally, I do research at Technical University of Vienna where we use a lot of PyTorch because of the easy implementation, install and the "debuggability". Therefore, I recommend PyTorch. If you are doing research, this comes in handy. Feel free to question my statement if you think differently.:)

$\endgroup$
1
  • $\begingroup$ Does anyone in your lab group use Tensorflow as well? I am sort of confused why Tensorflow is still seemingly more popular despite Pytorch being accepted as the easier to use library with identical (?) capabilities? $\endgroup$
    – anonuser01
    Dec 19, 2018 at 15:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.