Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

super(type, obj): obj must be an instance or subtype of type in Keras

I implement the following to build tiny yolo v2 from scratch using Keras with Tensorflow backend

My code was working fine in Keras 2.1.5 But when i updated to Keras 2.1.6 i ran in to an error

""kernel_constraint=None,

TypeError: super(type, obj): obj must be an instance or subtype of type "" Please help me out Thank you so much

import tensorflow as tf
import keras
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential
from keras.layers import Dense, Conv2D, MaxPooling2D, Dropout, Flatten, 
Reshape, LeakyReLU, BatchNormalization 

def yolo():
    model = Sequential()
    model.add(Conv2D(16,(3,3), padding='same',input_shape=(416,416,3),data_format='channels_last'))
    model.add(LeakyReLU(alpha=0.1))
    model.add(MaxPooling2D(pool_size=(2,2)))

    model.add(Conv2D(32,(3,3), padding='same'))
    model.add(BatchNormalization(axis=-1))
    model.add(LeakyReLU(alpha=0.1))
    model.add(MaxPooling2D(pool_size=(2,2)))

    model.add(Conv2D(64,(3,3), padding='same'))
    model.add(BatchNormalization(axis=-1))
    model.add(LeakyReLU(alpha=0.1))
    model.add(MaxPooling2D(pool_size=(2,2)))

    model.add(Conv2D(128,(3,3), padding='same'))
    model.add(BatchNormalization(axis=-1))
    model.add(LeakyReLU(alpha=0.1))
    model.add(MaxPooling2D(pool_size=(2,2)))

    model.add(Conv2D(128,(3,3), padding='same'))
    model.add(BatchNormalization(axis=-1))
    model.add(LeakyReLU(alpha=0.1))
    model.add(MaxPooling2D(pool_size=(2,2)))

    model.add(Conv2D(12,(1,1), padding='same'))
    model.add(BatchNormalization(axis=-1))
    model.add(LeakyReLU(alpha=0.1))

    model.add(Reshape((13,13,2,6)))
    return model

model = yolo()
model.summary()
like image 376
Peetah Avatar asked May 08 '18 10:05

Peetah


1 Answers

It can be caused by working without restarting the python kernel after the update.

like image 149
Young Avatar answered Sep 22 '22 13:09

Young