-
Notifications
You must be signed in to change notification settings - Fork 761
/
copy.html
170 lines (160 loc) · 8.24 KB
/
copy.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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<title>Edward – ed.copy</title>
<!-- Mobile Specific Metas -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- FONT -->
<link href="https://fonts.googleapis.com/css?family=Lora:400,400i,700" rel="stylesheet">
<!-- CSS -->
<link rel="stylesheet" href="/css/normalize.css">
<link rel="stylesheet" href="/css/skeleton.css">
<!-- Dynamically resize logo for mobile -->
<style type="text/css">
.logo-width {
width: 100%;
box-sizing: border-box;
margin-bottom: 15%;
}
/* Roughly the point when website is single column */
@media (max-width: 850px) {
.logo-width {
width: 50%;
box-sizing: border-box;
margin-bottom: 5%;
}
}
/* Downgrade API's header styles without explicitly modifying their type. */
div.nine.columns h1 { text-align: left; }
div.nine.columns h1 { font-size: 3.0rem; line-height: 1.25; letter-spacing: -.1rem; }
div.nine.columns h2 { font-size: 2.4rem; line-height: 1.3; letter-spacing: -.1rem; }
div.nine.columns h3 { font-size: 2.4rem; line-height: 1.35; letter-spacing: -.08rem; }
div.nine.columns h4 { font-size: 1.8rem; line-height: 1.5; letter-spacing: -.05rem; }
div.nine.columns h5 { font-size: 1.5rem; line-height: 1.6; letter-spacing: 0; }
@media (min-width: 550px) {
div.nine.columns h1 { font-size: 3.6rem; }
div.nine.columns h2 { font-size: 3.0rem; }
div.nine.columns h3 { font-size: 3.0rem; }
div.nine.columns h4 { font-size: 2.5rem; }
div.nine.columns h5 { font-size: 1.5rem; }
}
</style>
<!-- KaTeX -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/contrib/auto-render.min.js"></script>
<!-- highlight.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/highlight.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/styles/github.min.css">
<!-- Favicon -->
<link rel="apple-touch-icon" sizes="57x57" href="/icons/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/icons/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/icons/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/icons/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/icons/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/icons/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/icons/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/icons/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="/icons/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/icons/android-chrome-192x192.png" sizes="192x192">
<link rel="icon" type="image/png" href="/icons/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="/icons/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/icons/manifest.json">
<link rel="mask-icon" href="/icons/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="/icons/favicon.ico">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-TileImage" content="/icons/mstile-144x144.png">
<meta name="msapplication-config" content="/icons/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
</head>
<body>
<div class="container">
<div class="row" style="margin-top: 5%">
<div class="three columns">
<h1><a href="/">Edward</a></h1>
<a href="/">
<center>
<img src="/images/edward.png" class="logo-width" alt="Edward" />
</center>
</a>
<a class="button u-full-width" href="/api/">API</a>
<hr style="margin-top: 1rem; margin-bottom: 1.5rem;"/>
<a class="button u-full-width" href="/api/reference">Reference</a>
<a class="button u-full-width" href="/api/ed/criticisms">ed.criticisms</a>
<a class="button u-full-width" href="/api/ed/inferences">ed.inferences</a>
<a class="button u-full-width" href="/api/ed/models">ed.models</a>
<a class="button u-full-width" href="/api/ed/util">ed.util</a>
<a class="button u-full-width" href="/api/observations">observations</a>
<div class="row" style="padding-bottom: 5%"> </div>
<a class="button2 u-pull-right" style="padding-right:10%"
href="https://github.com/blei-lab/edward">
<span style="vertical-align:middle;">Github</span>
<img src="/images/github-mark.svg" style="vertical-align:middle;"
alt="Edward on Github" />
</a>
<div class="row" style="padding-bottom: 5%"> </div>
</div>
<div class="nine columns">
<div itemscope itemtype="http://developers.google.com/ReferenceObject">
<meta itemprop="name" content="ed.copy" />
</div>
<h1 id="ed.copy">ed.copy</h1>
<h3 id="aliases">Aliases:</h3>
<ul>
<li><code>ed.copy</code></li>
<li><code>ed.util.copy</code></li>
</ul>
<pre class="python"><code>copy(
org_instance,
dict_swap=None,
scope='copied',
replace_itself=False,
copy_q=False,
copy_parent_rvs=True
)</code></pre>
<p>Defined in <a href="https://github.com/blei-lab/edward/tree/master/edward/util/random_variables.py"><code>edward/util/random_variables.py</code></a>.</p>
<p>Build a new node in the TensorFlow graph from <code>org_instance</code>, where any of its ancestors existing in <code>dict_swap</code> are replaced with <code>dict_swap</code>’s corresponding value.</p>
<p>Copying is done recursively. Any <code>Operation</code> whose output is required to copy <code>org_instance</code> is also copied (if it isn’t already copied within the new scope).</p>
<p><code>tf.Variable</code>s, <code>tf.placeholder</code>s, and nodes of type <code>Queue</code> are always reused and not copied. In addition, <code>tf.Operation</code>s with operation-level seeds are copied with a new operation-level seed.</p>
<h4 id="args">Args:</h4>
<ul>
<li><b><code>org_instance</code></b>: RandomVariable, tf.Operation, tf.Tensor, or tf.Variable. Node to add in graph with replaced ancestors.</li>
<li><b><code>dict_swap</code></b>: dict. Random variables, variables, tensors, or operations to swap with. Its keys are what <code>org_instance</code> may depend on, and its values are the corresponding object (not necessarily of the same class instance, but must have the same type, e.g., float32) that is used in exchange.</li>
<li><b><code>scope</code></b>: str. A scope for the new node(s). This is used to avoid name conflicts with the original node(s).</li>
<li><b><code>replace_itself</code></b>: bool. Whether to replace <code>org_instance</code> itself if it exists in <code>dict_swap</code>. (This is used for the recursion.)</li>
<li><b><code>copy_q</code></b>: bool. Whether to copy the replaced tensors too (if not already copied within the new scope). Otherwise will reuse them.</li>
<li><b><code>copy_parent_rvs</code></b>: Whether to copy parent random variables <code>org_instance</code> depends on. Otherwise will copy only the sample tensors and not the random variable class itself.</li>
</ul>
<h4 id="returns">Returns:</h4>
<p>RandomVariable, tf.Variable, tf.Tensor, or tf.Operation. The copied node.</p>
<h4 id="raises">Raises:</h4>
<p>TypeError. If <code>org_instance</code> is not one of the above types.</p>
<h4 id="examples">Examples</h4>
<pre class="python"><code>x = tf.constant(2.0)
y = tf.constant(3.0)
z = x * y
qx = tf.constant(4.0)
# The TensorFlow graph is currently
# `x` -> `z` <- y`, `qx`
# This adds a subgraph with newly copied nodes,
# `qx` -> `copied/z` <- `copied/y`
z_new = ed.copy(z, {x: qx})
sess = tf.Session()
sess.run(z)
6.0
sess.run(z_new)
12.0</code></pre>
</div>
</div>
<div class="row" style="padding-bottom: 25%"> </div>
</div>
<script>
hljs.initHighlightingOnLoad();
renderMathInElement(document.body);
</script>
</body>
</html>