title: Keras: "must compile model before using it" despite compile() is used
body: <p>I want to create and train a CNN model in Keras for classification of banknotes. Creating models works fine with simple tutorials but not with the architecture I adopt from this <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5539635/" rel="noreferrer">paper</a>.
  Keras outputs: <code>RuntimeError('You must compile your model before using it.')</code> after <code>fit_generator()</code> is called.</p>
  
  <p>I use the tensorflow backend if that is of relevance.</p>
  
  <hr>
  
  <p>Model is defined in <code>model.py</code>:</p>
  
  <pre><code>from keras.layers import ...
  model = Sequential() 
  model.add(some_layer)
  
  ... #according to the paper
  
  model.add(some_layer)
  model.add(Dense(#output_classes, activation='softmax') #last layer
  
  model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
  </code></pre>
  
  <p>The <code>model</code> is then used from <code>start_train.py</code>:</p>
  
  <pre><code>from model import model as m
  
  #some ImageGenerator stuff as input
  
  m.fit_generator( #training on train_data
          train_pics,
          steps_per_epoch=#steps,
          epochs=#epochs,
          validation_data=test_pics,
  </code></pre>
  
  <p>As far as I understood it the process in Keras is as follows:</p>
  
  <ol>
  <li>Define model</li>
  <li>Compile model</li>
  <li>(If wanted evaluate() &amp; summary() can be used now after the compilation)</li>
  <li>Fit model</li>
  <li>Evaluate model.</li>
  </ol>
  
  <p>I tested if <code>model.py</code> is accessed before calling <code>fit_generator()</code> and it works properly. I'm out of ideas and wondering what I'm doing wrong especially since the same set-up works fine with a basic model/architecture.</p>
  
  <p>Any help is highly appreciated! :)</p>