Page 143 - GTM-4-1
P. 143

Global Translational Medicine                                      MRgFUS sonication parameters prediction



            Appendix

            The convolutional neural network code snippet to estimate optimal magnetic resonance imaging-guided focused
            ultrasound temperature.
            # Function to build the neural network model

            build_model <- function() [
            model <- keras_model_sequential()
            model %>%
            layer_dense(units = 64,
                   input_shape = dim(x_train)(2),
               kernel_regularizer = regularizer_l2(l = 0,001)) %>%
            layer_activation_relu() %>%
            layer_dense(units = 128, activation = ‘relu’) %>%
            layer_dropout(0.6) %>%

            layer_dense(units = 64, activation = ‘relu’) %>%
            layer_dense(units = 1)
            model %>% compile(
                   loss = “mse”,
                   optimizer = optimizer_rmsprop(),
                   metrics = list(“mean_absolute_error”)
            model

            model <- build_model()
            print_dot_callback <- callback_lambda(
                   on_epoch_end = function(epoch, logs) [
                   if (epoch %% 80 == 0) cat(“\n”)
                   cat(“.”)
            early_stop <- callback_early_stopping(monitor = “val_loss”, patience = 20)
            epochs <- 200
            # Model training
            history <- model %>% fit(

                   x_train,
                   y_train,
                   epochs = epochs,
                   validation_split = 0,2,
                   verbose = 1,
                   callbacks = list(early_stop, print_dot_callback)








            Volume 4 Issue 1 (2025)                        135                              doi: 10.36922/gtm.5419
   138   139   140   141   142   143   144   145   146   147   148