-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathConcept04_cifar.Rmd
77 lines (46 loc) · 1.22 KB
/
Concept04_cifar.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---
title: "Concept04_cifar"
output: github_document
---
학습 정확도 추이
```{r}
library(ggplot2)
library(data.table)
load("accuracy_list.RData")
accuracy_dt <- rbindlist(accuracy_list)
ggplot(accuracy_dt, aes(epoch, accu)) + geom_point() +
geom_line(group=1) + ylab("accuracy") + geom_smooth()
```
학습된 가중치 시각화
```{r}
source("Concept01_cifar.R")
```
```{r,cache=T}
names_data_labels <- read_data('./cifar-10-batches-py')
```
커널 매트릭스 출력
```{r}
library(tensorflow)
source("Concept03_cnn.R")
source("Concept02_convolution.R")
sess <- tf$InteractiveSession()
saver$restore(sess, "saver/model_1000.chkp-1")
w1_val <- sess$run(W1)
print('weights1:')
show_weights(w1_val)
```
```{r,fig.height=3, fig.width=5}
img_idx <- 222
names_data_labels$names[names_data_labels$labels[img_idx] + 1]
raw_data <- names_data_labels$data[img_idx,]
raw_img <- t(array(raw_data, dim = c(24,24)))
par(mar = rep(1, 4))
image(raw_img, axes = F, col = grey(seq(0, 1, length = 256)))
```
콘볼루션 적용 후 출력 이미지
```{r}
conv_res <- sess$run(conv_out2, feed_dict=dict(x=matrix(names_data_labels$data[img_idx,], ncol=576)))
print(dim(conv_res))
show_conv_results(conv_res)
sess$close()
```