Why is my model twice as fast in Tensorflow than in Keras?

594 Views Asked by At

Am doing the udacity deep learning course which uses tensorflow. I have tried to replicate one of the assignments in keras with tensorflow backend but it is substantially slower taking almost 3 minutes compared with 1.5 minutes for tensorflow. It takes even longer with theano backend - almost 4 minutes. I am not using the GPU.

Is there a simple explanation? I was wondering if tensorflow makes better use of multi-processing by putting different nodes of the graph on different processors?

1

There are 1 best solutions below

0
On

Keras beginners mistake. In Keras when you add Dense(20, input_dim=20) this adds a hidden layer and an input layer. The parameter input_dim is the input layer. In tensorflow you add the input layer explicitly. Hence for my Keras model I accidentally added an extra layer and it took twice as long to complete.