Sigrid Keydana, Trivadis
2017/22/09
Easy? Difficult?
What are the correct pixel values for a “bike” feature?
We need:
The loss (or cost) function indicates the cost incurred from false prediction / misclassification.
Probably the best-known loss functions in machine learning are mean squared error:
\( \frac{1}{n} \sum_n{(\hat{y} - y)^2} \)
and cross entropy :
\( - \sum_j{t_j log(y_j)} \)
4 steps
model <- keras_model_sequential()
model %>%
layer_conv_2d(
filter = 32, kernel_size = c(3,3), padding = "same", input_shape = c(target_height, target_width, 3) ) %>%
layer_activation("relu") %>%
layer_max_pooling_2d(pool_size = c(2,2)) %>%
layer_conv_2d(filter = 32, kernel_size = c(3,3)) %>%
layer_activation("relu") %>%
layer_max_pooling_2d(pool_size = c(2,2)) %>%
layer_conv_2d(filter = 64, kernel_size = c(3,3), padding = "same") %>%
layer_activation("relu") %>%
layer_max_pooling_2d(pool_size = c(2,2)) %>%
layer_flatten() %>%
layer_dense(64) %>%
layer_activation("relu") %>%
layer_dropout(0.5) %>%
layer_dense(2) %>%
layer_activation("softmax")
opt <- optimizer_rmsprop(lr = 0.001, decay = 1e-6)
model %>% compile(
loss = "binary_crossentropy",
optimizer = opt,
metrics = "accuracy"
)
train_datagen <- image_data_generator(
rescale = 1/255,
rotation_range = 80,
width_shift_range = 0.2,
height_shift_range = 0.2,
horizontal_flip = TRUE,
vertical_flip = TRUE,
shear_range = 0.2,
zoom_range = 0.2,
fill_mode = "wrap"
)
model_name <- "model_filter323264_kernel3_epochs20_lr001.h5"
model <- load_model_hdf5(model_name)
Crack (top row - easy)
class probabilities(crack/no crack): 0.92 / 0.08
No crack (top row - easy)
class probabilities(crack/no crack): 0.35 / 0.65
Crack (middle row - medium)
class probabilities(crack/no crack): 0.59 / 0.41
No crack (middle row - medium)
class probabilities(crack/no crack): 0.42 / 0.58
Crack (bottom row - difficult)
class probabilities(crack/no crack): 0.32 / 0.68
No crack (bottom row - difficult)
class probabilities(crack/no crack): 0.63 / 0.37
base_model <- application_vgg16(weights = 'imagenet', include_top = FALSE)
for (layer in base_model$layers)
layer$trainable <- FALSE
# add our own fully connected layer (with dropout!)
… this means?
THANK YOU!