simon
simon

Reputation: 2831

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

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?

Upvotes: 2

Views: 597

Answers (1)

simon
simon

Reputation: 2831

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.

Upvotes: 1

Related Questions