| materialize | R Documentation |
This will materialize a lazy_tensor() or a data.frame() / list() containing – among other things –
lazy_tensor() columns.
I.e. the data described in the underlying DataDescriptors is loaded for the indices in the lazy_tensor(),
is preprocessed and then put unto the specified device.
Because not all elements in a lazy tensor must have the same shape, a list of tensors is returned by default.
If all elements have the same shape, these tensors can also be rbinded into a single tensor (parameter rbind).
materialize(x, device = "cpu", rbind = FALSE, ...)
## S3 method for class 'list'
materialize(x, device = "cpu", rbind = FALSE, cache = "auto", ...)
x |
(any) |
device |
( |
rbind |
( |
... |
(any) |
cache |
( |
Materializing a lazy tensor consists of:
Loading the data from the internal dataset of the DataDescriptor.
Processing these batches in the preprocessing Graphs.
Returning the result of the PipeOp pointed to by the DataDescriptor (pointer).
With multiple lazy_tensor columns we can benefit from caching because:
a) Output(s) from the dataset might be input to multiple graphs.
b) Different lazy tensors might be outputs from the same graph.
For this reason it is possible to provide a cache environment. The hash key for a) is the hash of the indices and the dataset. The hash key for b) is the hash of the indices, dataset and preprocessing graph.
(list() of lazy_tensors or a lazy_tensor)
lt1 = as_lazy_tensor(torch_randn(10, 3))
materialize(lt1, rbind = TRUE)
materialize(lt1, rbind = FALSE)
lt2 = as_lazy_tensor(torch_randn(10, 4))
d = data.table::data.table(lt1 = lt1, lt2 = lt2)
materialize(d, rbind = TRUE)
materialize(d, rbind = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.