layer_learnable_array: Initialize Learnable Layer

Description Usage Arguments Value Examples

View source: R/2-layers-learnable.R

Description

This function creates a layer of learnable weights. It requires connection to an input layer, but does not use the input. Instead, the values of the layer are the manifestation of learnable weights.

Usage

1
layer_learnable_array(input, array_dim, name = NULL)

Arguments

input

The incoming layer.

array_dim

The dimensions of the learnable kernel.

name

A string. The prefix label for all layers.

Value

A layer of learnable weights.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
library(keras)
library(caress)
set.seed(1)
index <- sample(1:nrow(iris))
x <- as.matrix(iris[index,1:4])
y <- to_categorical(as.numeric(iris[index,5])-1)
k_clear_session()
input <- from_input(x)
weight <- input %>%
  layer_learnable_array(4) %>%
  layer_reshape(c(4,1))
target <- layer_kernel_dot(input, weight) %>%
  layer_flatten() %>%
  to_output(y)
m <- prepare(input, target)
build(m, x, y, batch_size = 4, epochs = 100)

tpq/caress documentation built on March 11, 2021, 8:03 p.m.