'Tensorflow does not compile model

I have been trying to compile a pre-defined CNN model in a function but function call gives an error in a python notebook as described below. I'll be grateful if someone can help. Function is as follows:

def compile_model(model):

      model.compile(optimizer=optimizers.Adam(learning_rate=1e-4),loss='categorical_crossentropy',metrics=['accuracy']) 

Function call:

compile_model(model)

Error

---> 14     model.compile(optimizer=optimizers.Adam(learning_rate=1e-4),loss='categorical_crossentropy',metrics=['accuracy'])
     15 

AttributeError: 'NoneType' object has no attribute 'compile'



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source