---

title: AFN


keywords: fastai
sidebar: home_sidebar

summary: "A pytorch implementation of AFN."
description: "A pytorch implementation of AFN."
nb_path: "nbs/models/models.afn.ipynb"
---
<!--

#################################################
### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ###
#################################################
# file to edit: nbs/models/models.afn.ipynb
# command to build the docs after a change: nbdev_build_docs

-->

<div class="container" id="notebook-container">
        
    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h2 id="LNN" class="doc_header"><code>class</code> <code>LNN</code><a href="https://github.com/RecoHut-Projects/recohut/tree/master/recohut/models/afn.py#L13" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>LNN</code>(<strong><code>num_fields</code></strong>, <strong><code>embed_dim</code></strong>, <strong><code>LNN_dim</code></strong>, <strong><code>bias</code></strong>=<em><code>False</code></em>) :: <code>Module</code></p>
</blockquote>
<p>A pytorch implementation of LNN layer
Input shape</p>

<pre><code>- A 3D tensor with shape: ``(batch_size,field_size,embedding_size)``.
</code></pre>
<p>Output shape</p>

<pre><code>- 2D tensor with shape:``(batch_size,LNN_dim*embedding_size)``.
</code></pre>
<p>Arguments</p>

<pre><code>- **in_features** : Embedding of feature.
- **num_fields**: int.The field size of feature.
- **LNN_dim**: int.The number of Logarithmic neuron.
- **bias**: bool.Whether or not use bias in LNN.</code></pre>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h2 id="AFN" class="doc_header"><code>class</code> <code>AFN</code><a href="https://github.com/RecoHut-Projects/recohut/tree/master/recohut/models/afn.py#L61" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>AFN</code>(<strong><code>field_dims</code></strong>, <strong><code>embed_dim</code></strong>, <strong><code>LNN_dim</code></strong>, <strong><code>mlp_dims</code></strong>, <strong><code>dropouts</code></strong>) :: <code>Module</code></p>
</blockquote>
<p>A pytorch implementation of AFN.
Reference:
    Cheng W, et al. Adaptive Factorization Network: Learning Adaptive-Order Feature Interactions, 2019.</p>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<blockquote><p><strong>References:-</strong>- Cheng W, et al. Adaptive Factorization Network: Learning Adaptive-Order Feature Interactions, 2019.</p>
<ul>
<li><a href="https://github.com/rixwew/pytorch-fm/blob/master/torchfm/model/afn.py">https://github.com/rixwew/pytorch-fm/blob/master/torchfm/model/afn.py</a></li>
</ul>
</blockquote>

</div>
</div>
</div>
</div>
 

