Compare tensorflow
and dlib
models
#3002
Answered
by
arrufat
UlrichVonRekkenin
asked this question in
Q&A
-
Hi there, I'm trying to reproduce few tf example and I faced with the problem of mapping tf model to dlib. I check using dot notation. For instance first one: inputs = Input(shape=(26, 34, 1))
net = Conv2D(32, kernel_size=3, strides=1, padding='same', activation='relu')(inputs)
net = MaxPooling2D(pool_size=2)(net)
net = Conv2D(64, kernel_size=3, strides=1, padding='same', activation='relu')(net)
net = MaxPooling2D(pool_size=2)(net)
net = Conv2D(128, kernel_size=3, strides=1, padding='same', activation='relu')(net)
net = MaxPooling2D(pool_size=2)(net)
net = Flatten()(net)
net = Dense(512)(net)
net = Activation('relu')(net)
net = Dense(1)(net)
outputs = Activation('sigmoid')(net)
model = Model(inputs=inputs, outputs=outputs)
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['acc']) and second one: namespace dnn {
using namespace dlib;
template<size_t NUMS, typename SUBNET> using layer = max_pool<3, 3, 1, 1, relu<con<NUMS, 1, 1, 1, 1, SUBNET>>>;
using netType = loss_binary_log<sig<fc<1, relu<fc<512, layer<128, layer<64, layer<32, input<matrix<unsigned char>>>>>>>>>>;
} |
Beta Was this translation helpful? Give feedback.
Answered by
arrufat
Sep 2, 2024
Replies: 2 comments 21 replies
-
You don't need a sigmoid in the dlib model, it's already included in that loss layer. |
Beta Was this translation helpful? Give feedback.
20 replies
-
from keras.applications.mobilenet_v2 import MobileNetV2
mobilenet = MobileNetV2(weights="imagenet",include_top=False,input_tensor=Input(shape=(160,160,3)))
mobilenet.trainable = False And this one. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Anyway, after further inspection, you got the kernel sizes for convolutions and max pooling layers wrong.
Here's my attempt: