Combines generators created by generator_initialize into a single generator.
Usage
generator_fasta_label_folder_wrapper(
val,
batch_size = NULL,
path = NULL,
voc_len = NULL,
maxlen = NULL,
gen_list = NULL,
set_learning = NULL
)Arguments
- val
Train or validation generator.
- batch_size
Number of samples in one batch.
- path
Path to input files.
- voc_len
Length of vocabulary.
- maxlen
Length of predictor sequence.
- gen_list
List of generator functions.
- set_learning
When you want to assign one label to set of samples. Only implemented for
train_type = "label_folder". Input is a list with the following parameterssamples_per_target: how many samples to use for one target.maxlen: length of one sample.reshape_mode:"time_dist", "multi_input"or"concat".If
reshape_modeis"multi_input", generator will producesamples_per_targetseparate inputs, each of lengthmaxlen(model should havesamples_per_targetinput layers).If reshape_mode is
"time_dist", generator will produce a 4D input array. The dimensions correspond to(batch_size, samples_per_target, maxlen, length(vocabulary)).If
reshape_modeis"concat", generator will concatenatesamples_per_targetsequences of lengthmaxlento one long sequence.
If
reshape_modeis"concat", there is an additionalbuffer_lenargument. Ifbuffer_lenis an integer, the subsequences are interspaced withbuffer_lenrows. The input length is (maxlen\(*\)samples_per_target) +buffer_len\(*\) (samples_per_target- 1).
Examples
if (FALSE) { # reticulate::py_module_available("tensorflow")
# create two folders with dummy fasta files
path_input_1 <- tempfile()
dir.create(path_input_1)
create_dummy_data(file_path = path_input_1, num_files = 2, seq_length = 5,
num_seq = 2, vocabulary = c("a", "c", "g", "t"))
path_input_2 <- tempfile()
dir.create(path_input_2)
create_dummy_data(file_path = path_input_2, num_files = 3, seq_length = 7,
num_seq = 5, vocabulary = c("a", "c", "g", "t"))
maxlen <- 5
p <- c(path_input_1, path_input_1)
gen_list <- generator_initialize(directories = p,
batch_size = 4, maxlen = maxlen)
gen <- generator_fasta_label_folder_wrapper(val = FALSE, batch_size = 8,
path = p, voc_len = 4,
maxlen = maxlen,
gen_list = gen_list)
z <- gen()
dim(z[[1]])
z[[2]]
}
