Does K.function method of Keras with Tensorflow backend work with network layers?

后端 未结 2 1006
囚心锁ツ
囚心锁ツ 2021-02-02 04:09

I recently have started using Keras to build neural networks. I built a simple CNN to classify MNIST dataset. Before learning the model I used K.set_image_dim_ordering(\'t

2条回答
  •  长情又很酷
    2021-02-02 05:00

    You should do the following changes:

    output_fn = K.function([input_layer], [output_layer])
    output_image = output_fn([input_image])
    

    K.function takes the input and output tensors as list so that you can create a function from many input to many output. In your case one input to one output.. but you need to pass them as a list none the less.

    Next K.function returns a tensor function and not a model object where you can use predict(). The correct way of using is just to call as a function

提交回复
热议问题