u_net {imageseg}R Documentation

Create a U-Net architecture

Description

Create a U-Net architecture

Usage

u_net(
  net_h,
  net_w,
  grayscale = FALSE,
  layers_per_block = 2,
  blocks = 4,
  n_class = 1,
  filters = 16,
  dropout = 0,
  batch_normalization = TRUE,
  kernel_initializer = "he_normal"
)

Arguments

net_h

Input layer height.

net_w

Input layer width.

grayscale

Defines input layer color channels - 1 if 'TRUE', 3 if 'FALSE'.

layers_per_block

Number of convolutional layers per block (can be 2 or 3)

blocks

Number of blocks in the model.

n_class

Number of classes.

filters

Integer, the dimensionality of the output space (i.e. the number of output filters in the convolution).

dropout

Dropout rate (between 0 and 1).

batch_normalization

Should batch normalization be used in the block?

kernel_initializer

Initializer for the kernel weights matrix.

Details

This function creates a U-Net model architecture according to user input. It allows flexibility regarding input, output and the hidden layers. See the package vignette for examples.

The function was adapted and slightly modified from the u_net() function in the platypus package (https://github.com/maju116/platypus/blob/master/R/u_net.R).

Differences compared to platypus implementation:

Value

U-Net model.

A keras model as returned by keras_model

Examples

## Not run: 
# U-Net model for 256x256 pixel RGB input images with a single output class
# this model was used for canopy density

model <- u_net(net_h = 256, 
net_w = 256, 
grayscale = FALSE,
filters = 32,
blocks = 4,
layers_per_block = 2
)

# several arguments above were not necessary because they were kept at their default. 
# Below is the same model, but shorter:

model <- u_net(net_h = 256, 
net_w = 256, 
filters = 32
)

model


## End(Not run)


[Package imageseg version 0.5.0 Index]