|
1 | 1 |
|
2 | 2 | #' Tensor shape utility |
3 | 3 | #' |
4 | | -#' This function can be used to create or get the shape of an object. |
| 4 | +#' This function can be used to get or create a tensor shape. |
5 | 5 | #' |
6 | 6 | #' # Examples |
7 | 7 | #' ```{r} |
|
53 | 53 | #' A useful pattern is to unpack the `shape()` with `%<-%`, like this: |
54 | 54 | #' ```r |
55 | 55 | #' c(batch_size, seq_len, channels) %<-% shape(x) |
| 56 | +#' |
| 57 | +#' # `%<-%` also has support for skipping values |
| 58 | +#' # during unpacking with `.` and `...`. For example, |
| 59 | +#' # To retrieve just the first and/or last dim: |
| 60 | +#' c(batch_size, ...) %<-% shape(x) |
| 61 | +#' c(batch_size, ., .) %<-% shape(x) |
| 62 | +#' c(..., channels) %<-% shape(x) |
| 63 | +#' c(batch_size, ..., channels) %<-% shape(x) |
| 64 | +#' c(batch_size, ., channels) %<-% shape(x) |
56 | 65 | #' ``` |
57 | 66 | #' |
58 | 67 | #' ```{r} |
|
98 | 107 | #' via `as.integer()`. |
99 | 108 | #' |
100 | 109 | #' @returns A list with a `"keras_shape"` class attribute. Each element of the |
101 | | -#' list will be either a) `NULL`, b) an integer or c) a scalar integer tensor |
102 | | -#' (e.g., when supplied a TF tensor with a unspecified dimension in a function |
| 110 | +#' list will be either a) `NULL`, b) an R integer or c) a scalar integer tensor |
| 111 | +#' (e.g., when supplied a TF tensor with an unspecified dimension in a function |
103 | 112 | #' being traced). |
104 | 113 | #' |
105 | 114 | #' @export |
@@ -154,7 +163,7 @@ shape <- function(...) { |
154 | 163 |
|
155 | 164 | #' @export |
156 | 165 | #' @rdname shape |
157 | | -#' @param x A 'keras_shape' object |
| 166 | +#' @param x A `keras_shape` object. |
158 | 167 | #' @param prefix Whether to format the shape object with a prefix. Defaults to |
159 | 168 | #' `"shape"`. |
160 | 169 | format.keras_shape <- function(x, ..., prefix = TRUE) { |
|
0 commit comments