Skip to content

Commit 14f5b87

Browse files
authored
Merge pull request #8 from oneilsh/docfixes
Docfixes
2 parents 530c3cd + 4f453e2 commit 14f5b87

36 files changed

+19635
-19008
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: tidytensor
22
Type: Package
33
Title: TidyTensor
4-
Version: 0.9.1
4+
Version: 1.0.0
55
Date: 2018-12-05
66
Authors@R: c(
77
person("Shawn T.", "O'Neil", middle = NULL, "shawn@tislab.org", role = c("aut", "cre"),

README.md

Lines changed: 80 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![DOI](https://zenodo.org/badge/160564655.svg)](https://zenodo.org/badge/latestdoi/160564655)
1+
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4968727.svg)](https://doi.org/10.5281/zenodo.4968727)
22
[![status](https://joss.theoj.org/papers/07ef2e53d083c0eea30c0d08eef0f1cb/status.svg)](https://joss.theoj.org/papers/07ef2e53d083c0eea30c0d08eef0f1cb)
33
[![R-CMD-check](https://github.com/oneilsh/tidytensor/workflows/R-CMD-check/badge.svg)](https://github.com/oneilsh/tidytensor/actions)
44
[![codecov](https://codecov.io/gh/oneilsh/tidytensor/branch/master/graph/badge.svg?token=GWMT57CGDK)](https://codecov.io/gh/oneilsh/tidytensor)
@@ -7,27 +7,100 @@
77
<br />
88
<img src="man/figures/tidytensor_transparent.png" height=200px/>
99

10-
(If you are reading this on GitHub, see the full [documentation](https://oneilsh.github.io/tidytensor/) on GitHub pages.)
10+
*If you are reading this on [GitHub](https://github.com/oneilsh/tidytensor) be sure to check out the full [documentation](https://oneilsh.github.io/tidytensor/) on GitHub pages.*
1111

12-
TidyTensor is an R package for inspecting and manipulating tensors (multidimensional arrays). It provides an improved `print()` function for summarizing structure, named tensors, conversion to data frames, and high-level manipulation functions. Designed to complement the excellent `keras` package, functionality is layered on top of base R types.
12+
TidyTensor is an R package for inspecting and manipulating tensors (multidimensional arrays). It provides an improved `print()` for summarizing structure, named tensors, conversion to data frames, and high-level manipulation functions. Designed to complement the `keras` package for deep learning in R, functionality is layered on top of base R types.
1313

1414
TidyTensor was inspired by a workshop I taught in deep learning with R, and a desire to explain and explore tensors in a more intuitive way.
1515

1616

1717
<br />
1818
<br />
1919

20-
## Installation and Usage
20+
## Installation
2121

2222
A simple `devtools::install_github("oneilsh/tidytensor")` will do it. If you don't have `devtools`, first grab it with `install.packages("devtools")`.
2323

24-
See the [Getting Started](https://oneilsh.github.io/tidytensor/articles/tidytensor.html) vignette for a summary of features and usage.
25-
2624
If you use TidyTensor, let us know in an [issue](https://github.com/oneilsh/tidytensor/issues/new)!
2725

2826
<br />
2927
<br />
3028

29+
## Examples and Usage
30+
31+
Here we provide just two basic examples of how TidyTensor can help illuminate data used for deep learning. See the [Getting Started](https://oneilsh.github.io/tidytensor/articles/tidytensor.html) vignette for more examples of visualizing tensor structure, filtering and data augmentation, producing train/test splits, and other handy features.
32+
33+
34+
Consider the `CIFAR10` dataset distributed with the `keras` library:
35+
36+
```
37+
## library(keras)
38+
cifar10_raw <- dataset_cifar10()$train$x
39+
```
40+
41+
TidyTensor can be used to plot the contained image data with the help of other `tidyverse` packages:
42+
43+
```
44+
## library(tidytensor)
45+
## library(ggplot2)
46+
## library(tidyr)
47+
48+
cifar10_raw %>%
49+
as.tidytensor() %>%
50+
set_ranknames(image, row, col, channel) %>%
51+
set_dimnames_for_rank(channel, R, G, B) %>%
52+
subset(image = 1:4) %>%
53+
as.data.frame() %>%
54+
spread(channel, value) %>%
55+
ggplot() +
56+
geom_tile(aes(x = col, y = row, fill = rgb(R, G, B, maxColorValue = 255))) +
57+
facet_wrap( ~ image) +
58+
coord_equal() +
59+
scale_y_reverse() +
60+
scale_fill_identity()
61+
```
62+
63+
<img src="man/figures/cifar_color.png" style="width: 60%; align: left" />
64+
65+
For a second example, we can start with a `keras` model and generate a function mapping inputs to internal feature map representations:
66+
67+
```
68+
vgg_model <- application_vgg16(include_top = FALSE, input_shape = c(32, 32, 3))
69+
70+
input <- vgg_model$input
71+
output <- get_layer(vgg_model, name = "block1_conv2")$output
72+
73+
# input shape (N, 32, 32, 3)
74+
# output shape (N, 32, 32, 64) tensor, where last rank are feature maps
75+
compute_featuremaps <- k_function(input, output)
76+
```
77+
78+
TidyTensor can then be used to feed a given set of input tensors through the function and visualize the resulting convolutional feature maps:
79+
80+
```
81+
(cifar10_raw / 255) %>%
82+
as.tidytensor() %>%
83+
set_ranknames(image, row, col, channel) %>%
84+
set_dimnames_for_rank(channel, R, G, B) %>%
85+
subset(image = 1:4) %>%
86+
compute_featuremaps() %>%
87+
as.tidytensor() %>%
88+
set_ranknames(image, row, col, featuremap) %>%
89+
subset(featuremap = 1:6) %>%
90+
as.data.frame() %>%
91+
ggplot() +
92+
geom_tile(aes(x = col, y = row, fill = value)) +
93+
facet_grid(image ~ featuremap) +
94+
coord_equal() +
95+
scale_y_reverse()
96+
```
97+
98+
<img src="man/figures/feature_maps.png" style="width: 80%; align: left" />
99+
100+
<br />
101+
<br />
102+
103+
31104
## Contributing
32105

33106
Pull requests welcome! Please see the [`CONTRIBUTING.md`](https://github.com/oneilsh/tidytensor/blob/master/CONTRIBUTING.md) file for details.
@@ -38,6 +111,7 @@ We are especially interested in additional methods for visualizing or summarizin
38111

39112
## Changelog
40113

114+
* v1.0.0: Minor documentation improvements, version 1.0 minted for JOSS publication
41115
* v0.9.1: preparation for JOSS submission, many documentation improvements, removing `allow_huge` option from `as.data.frame.tidytensor()`
42116
* v0.9.0: refactor `bottom` paramter of `print()` to `base_rank`
43117
* v0.8.2: minor bugfixes, new combine_ranks() function

docs/404.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/CONTRIBUTING.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/LICENSE-text.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/LICENSE.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/articles/index.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)