I am using keras and trying to train a classifier on 64x64 images.
I am trying to optimise my training pipeline and to catch the bottlenecks.
To this end I'm trying to create the simpler Keras model so that I know what time the whole process (loading image, data augmentation,...) takes with a very low charge on the GPU.
So far I managed to write:
def create_network_dummy():
INPUT_SHAPE = (64, 64, 1)
inputs = Input(INPUT_SHAPE)
out = MaxPooling2D(pool_size = (1,1), strides=(64,64), 1)(inputs)
model = Model(inputs=[inputs], outputs=[out])
return model
Is it possible to have an even smaller one ? Returning a constant won't do because it breaks the graph and keras will not allow it.
The standard way to save a functional model is to call model. save() to save the entire model as a single file. You can later recreate the same model from this file, even if the code that built the model is no longer available.
Keras is a neural network Application Programming Interface (API) for Python that is tightly integrated with TensorFlow, which is used to build machine learning models. Keras' models offer a simple, user-friendly way to define a neural network, which will then be built for you by TensorFlow.
I think there is no need to even use K.identity
:
inp = Input((64, 64, 1))
out = Lambda(lambda x: x)(inp)
model = Model(inp, out)
import keras.backend as K
from keras.layers import Input, Lambda
from keras.models import Model
inp = Input((64,64,1))
out = Lambda(lambda x: K.identity(x))(inp)
model = Model(inp,out) #You could even try Model(inp,inp)
??
If the idea is to have a model that does nothing, this seems the best.
You can return a constant too, you don't really need to "train" to see what you proposed, you can just "predict".
model.predict_generator(....)
inp = Input((64,64,1))
out = Lambda(lambda x: x[:,0,0])(inp)
model = Model(inp,out)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With