This is an automated email from the ASF dual-hosted git repository. git-site-role pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/asf-site by this push: new a44b1d0d426 Publishing website 2022/08/31 22:17:41 at commit 2e19b4f a44b1d0d426 is described below commit a44b1d0d426acc56cd04d370de65326a90513a9d Author: jenkins <bui...@apache.org> AuthorDate: Wed Aug 31 22:17:42 2022 +0000 Publishing website 2022/08/31 22:17:41 at commit 2e19b4f --- .../python/elementwise/runinference/index.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/website/generated-content/documentation/transforms/python/elementwise/runinference/index.html b/website/generated-content/documentation/transforms/python/elementwise/runinference/index.html index 05c04905344..834e4ac6568 100644 --- a/website/generated-content/documentation/transforms/python/elementwise/runinference/index.html +++ b/website/generated-content/documentation/transforms/python/elementwise/runinference/index.html @@ -44,10 +44,10 @@ Pydoc</a></td></table><p><br><br><br></p><p>Uses models to do local and remote i <span class=o>|</span> <span class=s1>'InputData'</span> <span class=o>>></span> <span class=n>beam</span><span class=o>.</span><span class=n>Create</span><span class=p>(</span><span class=n>unkeyed_data</span><span class=p>)</span> <span class=o>|</span> <span class=s1>'ConvertNumpyToTensor'</span> <span class=o>>></span> <span class=n>beam</span><span class=o>.</span><span class=n>Map</span><span class=p>(</span><span class=n>torch</span><span class=o>.</span><span class=n>Tensor</span><span class=p>)</span> <span class=o>|</span> <span class=s1>'PytorchRunInference'</span> <span class=o>>></span> <span class=n>RunInference</span><span class=p>(</span><span class=n>model_handler</span><span class=o>=</span><span class=n>model_handler</span><span class=p>)</span> - <span class=o>|</span> <span class=n>beam</span><span class=o>.</span><span class=n>Map</span><span class=p>(</span><span class=k>print</span><span class=p>))</span></code></pre></div></div></div><p><p class=notebook-skip>Output:</p><div class=snippet><div class="notebook-skip code-snippet without_switcher"><a class=copy type=button data-bs-toggle=tooltip data-bs-placement=bottom title="Copy to clipboard"><img src=/images/copy-icon.svg></a><pre><code>PredictionResult(example=tensor [...] -PredictionResult(example=tensor([40.]), inference=tensor([201.1165], grad_fn=<UnbindBackward>)) -PredictionResult(example=tensor([60.]), inference=tensor([300.3724], grad_fn=<UnbindBackward>)) -PredictionResult(example=tensor([90.]), inference=tensor([449.2563], grad_fn=<UnbindBackward>))</code></pre></div></div></p><h3 id=example-2-pytorch-keyed-model>Example 2: PyTorch keyed model</h3><p>In this example, we create a pipeline that uses a PyTorch RunInference transform on keyed data.</p><div class="language-py snippet"><div class="notebook-skip code-snippet"><a target=_blank type=button data-bs-toggle=tooltip data-bs-placement=bottom title="View source code" href=https:// [...] + <span class=o>|</span> <span class=n>beam</span><span class=o>.</span><span class=n>Map</span><span class=p>(</span><span class=k>print</span><span class=p>))</span></code></pre></div></div></div><p><p class=notebook-skip>Output:</p><div class=snippet><div class="notebook-skip code-snippet without_switcher"><a class=copy type=button data-bs-toggle=tooltip data-bs-placement=bottom title="Copy to clipboard"><img src=/images/copy-icon.svg></a><pre><code>PredictionResult(example=tensor [...] +PredictionResult(example=tensor([40.]), inference=tensor([201.1165])) +PredictionResult(example=tensor([60.]), inference=tensor([300.3724])) +PredictionResult(example=tensor([90.]), inference=tensor([449.2563]))</code></pre></div></div></p><h3 id=example-2-pytorch-keyed-model>Example 2: PyTorch keyed model</h3><p>In this example, we create a pipeline that uses a PyTorch RunInference transform on keyed data.</p><div class="language-py snippet"><div class="notebook-skip code-snippet"><a target=_blank type=button data-bs-toggle=tooltip data-bs-placement=bottom title="View source code" href=https://github.com/apache/beam/blob/mast [...] <a class=copy type=button data-bs-toggle=tooltip data-bs-placement=bottom title="Copy to clipboard"><img src=/images/copy-icon.svg></a><div class=highlight><pre class=chroma><code class=language-py data-lang=py><span class=kn>import</span> <span class=nn>apache_beam</span> <span class=kn>as</span> <span class=nn>beam</span> <span class=kn>import</span> <span class=nn>torch</span> <span class=kn>from</span> <span class=nn>apache_beam.ml.inference.base</span> <span class=kn>import</span> <span class=n>KeyedModelHandler</span> @@ -74,10 +74,10 @@ PredictionResult(example=tensor([90.]), inference=tensor([449.2563], grad_fn=< <span class=n>beam</span><span class=o>.</span><span class=n>Map</span><span class=p>(</span><span class=k>lambda</span> <span class=n>x</span><span class=p>:</span> <span class=p>(</span><span class=n>x</span><span class=p>[</span><span class=mi>0</span><span class=p>],</span> <span class=n>torch</span><span class=o>.</span><span class=n>Tensor</span><span class=p>([</span><span class=n>x</span><span class=p>[</span><span class=mi>1</span><span class=p>]])))</span> <span class=o>|</span> <span class=s1>'PytorchRunInference'</span> <span class=o>>></span> <span class=n>RunInference</span><span class=p>(</span><span class=n>model_handler</span><span class=o>=</span><span class=n>keyed_model_handler</span><span class=p>)</span> - <span class=o>|</span> <span class=n>beam</span><span class=o>.</span><span class=n>Map</span><span class=p>(</span><span class=k>print</span><span class=p>))</span></code></pre></div></div></div><p class=notebook-skip>Output:</p><div class=snippet><div class="notebook-skip code-snippet without_switcher"><a class=copy type=button data-bs-toggle=tooltip data-bs-placement=bottom title="Copy to clipboard"><img src=/images/copy-icon.svg></a><pre><code>('first_question', Predict [...] -('second_question', PredictionResult(example=tensor([108.]), inference=tensor([538.5867], grad_fn=<UnbindBackward>))) -('third_question', PredictionResult(example=tensor([1000.]), inference=tensor([4965.4019], grad_fn=<UnbindBackward>))) -('fourth_question', PredictionResult(example=tensor([1013.]), inference=tensor([5029.9180], grad_fn=<UnbindBackward>)))</code></pre></div></div><h3 id=example-3-sklearn-unkeyed-model>Example 3: Sklearn unkeyed model</h3><p>In this example, we create a pipeline that uses an SKlearn RunInference transform on unkeyed data.</p><div class="language-py snippet"><div class="notebook-skip code-snippet"><a target=_blank type=button data-bs-toggle=tooltip data-bs-placement=bottom tit [...] + <span class=o>|</span> <span class=n>beam</span><span class=o>.</span><span class=n>Map</span><span class=p>(</span><span class=k>print</span><span class=p>))</span></code></pre></div></div></div><p class=notebook-skip>Output:</p><div class=snippet><div class="notebook-skip code-snippet without_switcher"><a class=copy type=button data-bs-toggle=tooltip data-bs-placement=bottom title="Copy to clipboard"><img src=/images/copy-icon.svg></a><pre><code>('first_question', Predict [...] +('second_question', PredictionResult(example=tensor([108.]), inference=tensor([538.5867]))) +('third_question', PredictionResult(example=tensor([1000.]), inference=tensor([4965.4019]))) +('fourth_question', PredictionResult(example=tensor([1013.]), inference=tensor([5029.9180])))</code></pre></div></div><h3 id=example-3-sklearn-unkeyed-model>Example 3: Sklearn unkeyed model</h3><p>In this example, we create a pipeline that uses an SKlearn RunInference transform on unkeyed data.</p><div class="language-py snippet"><div class="notebook-skip code-snippet"><a target=_blank type=button data-bs-toggle=tooltip data-bs-placement=bottom title="View source code" href=https [...] <a class=copy type=button data-bs-toggle=tooltip data-bs-placement=bottom title="Copy to clipboard"><img src=/images/copy-icon.svg></a><div class=highlight><pre class=chroma><code class=language-py data-lang=py><span class=kn>import</span> <span class=nn>apache_beam</span> <span class=kn>as</span> <span class=nn>beam</span> <span class=kn>import</span> <span class=nn>numpy</span> <span class=kn>from</span> <span class=nn>apache_beam.ml.inference.base</span> <span class=kn>import</span> <span class=n>RunInference</span>