Converts the input to a DataDescriptor
.
Arguments
- x
(any)
Object to convert.- dataset_shapes
(named
list()
of (integer()
orNULL
))
The shapes of the output. Names are the elements of the list returned by the dataset. If the shape is notNULL
(unknown, e.g. for images of different sizes) the first dimension must beNA
to indicate the batch dimension.- ...
(any)
Further arguments passed to theDataDescriptor
constructor.
Examples
ds = dataset("example",
initialize = function() self$iris = iris[, -5],
.getitem = function(i) list(x = torch_tensor(as.numeric(self$iris[i, ]))),
.length = function() nrow(self$iris)
)()
as_data_descriptor(ds, list(x = c(NA, 4L)))
#> <DataDescriptor: 1 ops>
#> * dataset_shapes: [x: (NA,4)]
#> * input_map: (x) -> Graph
#> * pointer: nop.e65b00.x.output
#> * shape: [(NA,4)]
# if the dataset has a .getbatch method, the shapes are inferred
ds2 = dataset("example",
initialize = function() self$iris = iris[, -5],
.getbatch = function(i) list(x = torch_tensor(as.matrix(self$iris[i, ]))),
.length = function() nrow(self$iris)
)()
as_data_descriptor(ds2)
#> <DataDescriptor: 1 ops>
#> * dataset_shapes: [x: (NA,4)]
#> * input_map: (x) -> Graph
#> * pointer: nop.38ffb0.x.output
#> * shape: [(NA,4)]