Spaces:
Runtime error
Runtime error
# B3 ------------ | |
import tensorflow as tf | |
from tensorflow.keras.models import Sequential | |
from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten, Dense, Activation, Dropout, BatchNormalization | |
from tensorflow.keras import regularizers | |
# Create Model Structure | |
cnn_img_size = (256, 256) | |
channels = 3 | |
img_shape = (cnn_img_size[0], cnn_img_size[1], channels) | |
base_model = tf.keras.applications.efficientnet.EfficientNetB3(include_top= False, weights= "imagenet", input_shape= img_shape, pooling= 'max') | |
b3_model = Sequential([ | |
base_model, | |
BatchNormalization(axis= -1, momentum= 0.99, epsilon= 0.001), | |
Dense(256, kernel_regularizer= regularizers.l2(0.016), activity_regularizer= regularizers.l1(0.006), | |
bias_regularizer= regularizers.l1(0.006), activation= 'relu'), | |
Dropout(rate= 0.45, seed= 123), | |
Dense(4, activation= 'softmax') | |
]) | |
b3_model.load_weights("efficientnetb3.h5") |