title: How to insert Keras model into scikit-learn pipeline?
body: <p>I'm using a Scikit-Learn custom pipeline (<code>sklearn.pipeline.Pipeline</code>) in conjunction with <code>RandomizedSearchCV</code> for hyper-parameter optimization. This works great.</p>
  
  <p>Now I would like to insert a Keras model as a first step into the pipeline. Parameters of the model should be optimized. The computed (fitted) Keras model should then be used later on in the pipeline by other steps, so I think I have to store the model as a global variable so that the other pipeline steps can use it. Is this right?</p>
  
  <p>I know that Keras offers some wrappers for the Scikit-Learn API but the problem is that these wrappers already do classification / regression but I only want to compute the Keras model and nothing else.</p>
  
  <p>How can this be done?</p>
  
  <p>For example I have a method which returns the model:</p>
  
  <pre><code>def create_model(file_path, argument2,...):
      ...
      return model
  </code></pre>
  
  <p>The method needs some fixed parameters like a file path etc. but X and y is not needed (or can be ignored). The parameters of the model should be optimized (number of layers etc.).</p>