---
title: "Code for Session 11"
author: "Dr. Richard M. Crowley"
date: ""
output:
  html_notebook
---

Note that the directories used to store data are likely different on your computer, and such references will need to be changed before using any such code.

```{r helpers, warning=FALSE}
library(knitr)
library(kableExtra)
html_df <- function(text, cols=NULL, col1=FALSE, full=F) {
  if(!length(cols)) {
    cols=colnames(text)
  }
  if(!col1) {
    kable(text,"html", col.names = cols, align = c("l",rep('c',length(cols)-1))) %>%
      kable_styling(bootstrap_options = c("striped","hover"), full_width=full)
  } else {
    kable(text,"html", col.names = cols, align = c("l",rep('c',length(cols)-1))) %>%
      kable_styling(bootstrap_options = c("striped","hover"), full_width=full) %>%
      column_spec(1,bold=T)
  }
}
```

```{r}
library(tidyverse)
```

```{r}
print("Hello world!")
```

```{r, warning=F, message=F}
library(keras)
model <- load_model_hdf5("../../Data/Session_11-mnist_model.h5")
history <- readRDS('../../Data/Session_11-mnist_history.rds')
eval <- readRDS('../../Data/Session_11-mnist_eval.rds')
```

```{r, warning=F}
summary(model)
```

```{r, fig.height=4.5, fig.width=4}
plot(history)
```

```{r}
eval
```

```{r, warning=F, message=F}
model <- load_model_hdf5("../../Data/Session_11-tweet_model.h5")
history <- readRDS('../../Data/Session_11-tweet_history.rds')
eval <- readRDS('../../Data/Session_11-tweet_eval.rds')
```

```{r, message=F}
summary(model)
```

```{r, fig.height=4.5, fig.width=4, message=F}
plot(history)
```

```{r}
eval
```

```{r, message=F, warning=F, fig.height=4}
history <- readRDS('../../Data/Session_11-tweet_history-30epoch.rds')
plot(history)
```

```{r, message=F, warning=F}
model <- load_model_hdf5("../../Data/Session_11-tweet_model-alexnet.h5")
history <- readRDS('../../Data/Session_11-tweet_history-alexnet.rds')
```

```{r, message=F}
summary(model)
```

```{r, message=F, fig.height=4.5}
plot(history)
```

