forked from rstudio/keras3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
202 lines (185 loc) · 12.1 KB
/
index.html
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>R Interface to Keras • keras</title>
<!-- jquery --><script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script><!-- Bootstrap --><link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/cosmo/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script><!-- Font Awesome icons --><link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">
<!-- pkgdown --><link href="pkgdown.css" rel="stylesheet">
<script src="jquery.sticky-kit.min.js"></script><script src="pkgdown.js"></script><!-- mathjax --><script src="https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container template-vignette">
<header><div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">Keras for R</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="index.html">Home</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Articles
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li class="dropdown-header">Getting Started</li>
<li>
<a href="articles/sequential_model.html">Guide to the Sequential Model</a>
</li>
<li>
<a href="articles/functional_api.html">Guide to the Functional API</a>
</li>
<li>
<a href="articles/faq.html">Frequently Asked Questions</a>
</li>
<li class="divider">
</li>
<li class="dropdown-header">Using Keras</li>
<li>
<a href="articles/about_keras_models.html">About Keras Models</a>
</li>
<li>
<a href="articles/about_keras_layers.html">About Keras Layers</a>
</li>
<li>
<a href="articles/training_callbacks.html">Training Callbacks</a>
</li>
<li>
<a href="articles/applications.html">Pre-Trained Models</a>
</li>
</ul>
</li>
<li>
<a href="articles/examples/index.html">Examples</a>
</li>
<li>
<a href="reference/index.html">Reference</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/rstudio/keras">
<span class="fa fa-github"></span>
</a>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
<!--/.container -->
</div>
<!--/.navbar -->
</header><div class="row">
<div class="col-md-9">
<div class="contents">
<div id="r-interface-to-keras" class="section level1">
<div class="page-header"><h1 class="hasAnchor">
<a href="#r-interface-to-keras" class="anchor"></a>R interface to Keras</h1></div>
<p><a href="https://keras.io/">Keras</a> is a high-level neural networks API developed with a focus on enabling fast experimentation. <em>Being able to go from idea to result with the least possible delay is key to doing good research.</em> Use Keras if you need a deep learning library that:</p>
<ul>
<li>Allows for easy and fast prototyping (through user friendliness, modularity, and extensibility).</li>
<li>Supports both convolutional networks and recurrent networks, as well as combinations of the two.</li>
<li>Runs seamlessly on CPU and GPU.</li>
</ul>
<div id="getting-started-30-seconds-to-keras" class="section level2">
<h2 class="hasAnchor">
<a href="#getting-started-30-seconds-to-keras" class="anchor"></a>Getting started: 30 seconds to Keras</h2>
<p>The core data structure of Keras is a <strong>model</strong>, a way to organize layers. The simplest type of model is the Sequential model, a linear stack of layers. For more complex architectures, you should use the Keras functional API, which allows to build arbitrary graphs of layers.</p>
<p>Here is the Sequential model:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">library</span>(keras)
model <-<span class="st"> </span><span class="kw"><a href="reference/keras_model_sequential.html">keras_model_sequential</a></span>()
model %>%<span class="st"> </span>
<span class="st"> </span><span class="kw"><a href="reference/layer_dense.html">layer_dense</a></span>(<span class="dt">units =</span> <span class="dv">64</span>, <span class="dt">input_shape =</span> <span class="dv">100</span>) %>%<span class="st"> </span>
<span class="st"> </span><span class="kw"><a href="reference/layer_activation.html">layer_activation</a></span>(<span class="dt">activation =</span> <span class="st">'relu'</span>) %>%<span class="st"> </span>
<span class="st"> </span><span class="kw"><a href="reference/layer_dense.html">layer_dense</a></span>(<span class="dt">units =</span> <span class="dv">10</span>) %>%<span class="st"> </span>
<span class="st"> </span><span class="kw"><a href="reference/layer_activation.html">layer_activation</a></span>(<span class="dt">activation =</span> <span class="st">'softmax'</span>) %>%<span class="st"> </span>
<span class="st"> </span><span class="kw"><a href="reference/compile.html">compile</a></span>(
<span class="dt">loss =</span> <span class="st">'categorical_crossentropy'</span>,
<span class="dt">optimizer =</span> <span class="kw"><a href="reference/optimizer_sgd.html">optimizer_sgd</a></span>(<span class="dt">lr =</span> <span class="fl">0.02</span>),
<span class="dt">metrics =</span> <span class="kw">c</span>(<span class="st">'accuracy'</span>)
)</code></pre></div>
<p>You can now iterate on your training data in batches (<code>x_train</code> and <code>y_train</code> are R matrices):</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">model %>%<span class="st"> </span><span class="kw"><a href="reference/fit.html">fit</a></span>(x_train, y_train, <span class="dt">epochs =</span> <span class="dv">5</span>, <span class="dt">batch_size =</span> <span class="dv">32</span>)</code></pre></div>
<p>Evaluate your performance in one line:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">loss_and_metrics <-<span class="st"> </span>model %>%<span class="st"> </span><span class="kw"><a href="reference/evaluate.html">evaluate</a></span>(x_test, y_test, <span class="dt">batch_size =</span> <span class="dv">128</span>)</code></pre></div>
<p>Or generate predictions on new data:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">classes <-<span class="st"> </span>model %>%<span class="st"> </span><span class="kw">predict</span>(x_test, <span class="dt">batch_size =</span> <span class="dv">128</span>)</code></pre></div>
<p>Building a question answering system, an image classification model, a Neural Turing Machine, or any other model is just as fast. The ideas behind deep learning are simple, so why should their implementation be painful?</p>
<p>To learn more about Keras, you can check out these articles:</p>
<ul>
<li><p><a href="articles/sequential_model.html">Guide to the Sequential Model</a></p></li>
<li><p><a href="articles/functional_api.html">Guide to the Functional API</a></p></li>
<li><p><a href="articles/faq.html">Frequently Asked Questions</a></p></li>
</ul>
<p>The <a href="articles/examples">examples</a> demonstrate more advanced models including transfer learning, variational auto-encoding, question-answering with memory networks, text generation with stacked LSTMs, etc.</p>
<p>The <a href="reference/index.html">function reference</a> includes detailed information on all of the functions available in the package.</p>
</div>
<div id="installation" class="section level2">
<h2 class="hasAnchor">
<a href="#installation" class="anchor"></a>Installation</h2>
<ol style="list-style-type: decimal">
<li><p>The R interface to Keras uses <a href="https://rstudio.github.io/tensorflow/">TensorFlow</a> as it’s underlying computation engine. Therefore, you need to install TensorFlow (version 1.1 or higher) before using the package. Instructions for installing TensorFlow are here: <a href="https://www.tensorflow.org/install/" class="uri">https://www.tensorflow.org/install/</a>.</p></li>
<li>
<p>Then, install the Keras R package from GitHub:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">devtools::<span class="kw">install_github</span>(<span class="st">"rstudio/keras"</span>)</code></pre></div>
</li>
</ol>
</div>
<div id="why-this-name-keras" class="section level2">
<h2 class="hasAnchor">
<a href="#why-this-name-keras" class="anchor"></a>Why this name, Keras?</h2>
<p>Keras (κέρας) means horn in Greek. It is a reference to a literary image from ancient Greek and Latin literature, first found in the Odyssey, where dream spirits (Oneiroi, singular Oneiros) are divided between those who deceive men with false visions, who arrive to Earth through a gate of ivory, and those who announce a future that will come to pass, who arrive through a gate of horn. It’s a play on the words κέρας (horn) / κραίνω (fulfill), and ἐλέφας (ivory) / ἐλεφαίρομαι (deceive).</p>
<p>Keras was initially developed as part of the research effort of project ONEIROS (Open-ended Neuro-Electronic Intelligent Robot Operating System).</p>
<blockquote>
<p>“Oneiroi are beyond our unravelling –who can be sure what tale they tell? Not all that men look for comes to pass. Two gates there are that give passage to fleeting Oneiroi; one is made of horn, one of ivory. The Oneiroi that pass through sawn ivory are deceitful, bearing a message that will not be fulfilled; those that come out through polished horn have truth behind them, to be accomplished for men who see them.” Homer, Odyssey 19. 562 ff (Shewring translation).</p>
</blockquote>
</div>
</div>
</div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Links</h2>
<ul class="list-unstyled">
<li>Browse source code at <br><a href="https://github.com/rstudio/keras">https://github.com/rstudio/keras</a>
</li>
<li>Report a bug at <br><a href="https://github.com/rstudio/keras/issues">https://github.com/rstudio/keras/issues</a>
</li>
</ul>
<h2>License</h2>
<p><a href="https://opensource.org/licenses/mit-license.php">MIT</a> + file <a href="LICENSE">LICENSE</a></p>
<h2>Developers</h2>
<ul class="list-unstyled">
<li>François Chollet <br><small class="roles"> Author, copyright holder </small> </li>
<li>JJ Allaire <br><small class="roles"> Author, maintainer </small> </li>
<li>
<a href="https://www.rstudio.com"><img src="http://tidyverse.org/rstudio-logo.svg" height="24"></a> <br><small class="roles"> Copyright holder, funder </small> </li>
<li> Google <br><small class="roles"> Contributor, copyright holder, funder </small> </li>
<li><a href="authors.html">All authors...</a></li>
</ul>
</div>
</div>
<footer><div class="copyright">
<p>Developed by François Chollet, JJ Allaire, <a href="https://www.rstudio.com"><img src="http://tidyverse.org/rstudio-logo.svg" height="24"></a>, Google.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="http://hadley.github.io/pkgdown/">pkgdown</a>.</p>
</div>
</footer>
</div>
</body>
</html>