title: Model visualization error: 'file' not defined
body: <p>I am trying to use the <a href="https://keras.io/visualization/" rel="nofollow noreferrer">Keras visualization module</a>:</p>
  
  <pre><code># Begin a model
  model = Sequential()  
  model.add(Convolution2D(4,1,5,input_shape=(1,1,49),init='uniform',weights=None,border_mode='valid') )   
  model.add(Activation('tanh')) 
  model.add(MaxPooling2D(pool_size=(1, 2)))
  model.add(Flatten())  
  model.add(Dense(600,init='normal'))
  model.add(Activation('tanh'))   
  model.add(Dense(2, init='normal'))  
  model.add(Activation('softmax'))  
  model.summary()
  sgd = SGD(lr=list_lr[i], decay=0.0, momentum=0.1, nesterov=False)
  model.compile(loss='categorical_crossentropy', metrics=['accuracy'],optimizer=sgd)
  
  # using visualization
  from keras.utils.visualize_util import plot
  plot(model, to_file='/home/wj/DL/model.png')
  
  model.fit(X_train,train_label, batch_size=list_batch[j], nb_epoch=list_epoch[k],shuffle=False,verbose=2,validation_split=0.2)
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>Traceback (most recent call last):
  File "6.2.4.cnn.py", line 85, in  &lt;module&gt;
      plot(model, to_file='/home/wj/DL/model.png')
  File "/usr/local/lib/python3.4/dist-packages/keras/utils/visualize_util.py", line 67, in plot    dot.write_png(to_file)
  File "/usr/local/lib/python3.4/dist-packages/pydot.py", line 1809, in    &lt;lambda&gt;
      lambda path, f=frmt, prog=self.prog : self.write(path, format=f, prog=prog))
  File "/usr/local/lib/python3.4/dist-packages/pydot.py",    line 1895, in write    dot_fd = file(path, "w+b")
      NameError: name 'file' is not defined
  </code></pre>
  
  <p>What am I doing wrong?</p>