Learn R Programming

modello (version 0.1.1)

DataSet.Seq: R6 class representign a dataset of sequences to feed RNN

Description

R6 class representign a dataset of sequences to feed RNN

R6 class representign a dataset of sequences to feed RNN

Arguments

Methods

Public methods

Method new()

Initialisation method

Usage

DataSet.Seq$new(X, ls, yi, indexes = NULL)

Arguments

X

matrix/array

ls

integer, sequence length

yi

integer vector, subset of indices to return a targets

indexes

integer vector, a subset of indexes indicating the starting point fir the sequences

Method length()

Returns the length of the dataset

Usage

DataSet.Seq$length()

Examples

ds = DataSet.Seq$new(matrix(rnorm(100), 20), 5, 1)
ds$length() # 20

Method feed()

Feeds the data into an existing seqience or creating a new one

Usage

DataSet.Seq$feed(x, mode = "head")

Arguments

x

existing sequence, if NULL it creates a new one

mode

chectacter indicating the way to build the sequences

Examples

modello.init(100, 100, 100, 100)
ds = DataSet.Seq$new(matrix(rnorm(100), 20), 5, 1)
SEQ = ds$feed(NULL)
print(names(SEQ))
print(SEQ$x[[1]]$v)
print(SEQ$y$v)
ds$feed(SEQ)
print(SEQ$x[[1]]$v)
print(SEQ$y$v)
modello.close()

Method rewind()

Sets the data loader back of n previous states. Only available for "head" and "tail" modes.

Usage

DataSet.Seq$rewind(n, mode = "head")

Arguments

n

number of step to rewind

mode

rewind mode. Possibly the same as the feed mode.

Examples

ds = DataSet.Seq$new(matrix(rnorm(100), 20), 5, 1)
ds$..get.data..("head")
ds$..get.data..("head")
ds$rewind(2)
ds$..get.data..("head")
ds$..get.data..("head")

Method ..pop.index..()

Auxiliary method not to be called directly. It pops an index from the dataset according to the given method

Usage

DataSet.Seq$..pop.index..(mode = "head")

Arguments

mode

popping mode

Method ..feed..()

Auxiliary method. Not to be called directly.

Usage

DataSet.Seq$..feed..(x, mode)

Arguments

x

existing sequence, if NULL it creates a new one

mode

chectacter indicating the way to build the sequences

Method ..get.data..()

Auxiliary method. Not to be called directly.

Usage

DataSet.Seq$..get.data..(mode)

Arguments

mode

chectacter indicating the way to build the sequences

Method clone()

The objects of this class are cloneable with this method.

Usage

DataSet.Seq$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Details

It load the data from a R array

Examples

Run this code
# NOT RUN {
## ------------------------------------------------
## Method `DataSet.Seq$length`
## ------------------------------------------------

ds = DataSet.Seq$new(matrix(rnorm(100), 20), 5, 1)
ds$length() # 20

## ------------------------------------------------
## Method `DataSet.Seq$feed`
## ------------------------------------------------

modello.init(100, 100, 100, 100)
ds = DataSet.Seq$new(matrix(rnorm(100), 20), 5, 1)
SEQ = ds$feed(NULL)
print(names(SEQ))
print(SEQ$x[[1]]$v)
print(SEQ$y$v)
ds$feed(SEQ)
print(SEQ$x[[1]]$v)
print(SEQ$y$v)
modello.close()

## ------------------------------------------------
## Method `DataSet.Seq$rewind`
## ------------------------------------------------

ds = DataSet.Seq$new(matrix(rnorm(100), 20), 5, 1)
ds$..get.data..("head")
ds$..get.data..("head")
ds$rewind(2)
ds$..get.data..("head")
ds$..get.data..("head")
# }

Run the code above in your browser using DataLab