---

title: FNFM


keywords: fastai
sidebar: home_sidebar

summary: "A pytorch implementation of Field-aware Neural Factorization Machine."
description: "A pytorch implementation of Field-aware Neural Factorization Machine."
nb_path: "nbs/models/models.fnfm.ipynb"
---
<!--

#################################################
### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ###
#################################################
# file to edit: nbs/models/models.fnfm.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="FieldAwareFactorizationMachine" class="doc_header"><code>class</code> <code>FieldAwareFactorizationMachine</code><a href="https://github.com/RecoHut-Projects/recohut/tree/master/recohut/models/fnfm.py#L12" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>FieldAwareFactorizationMachine</code>(<strong><code>field_dims</code></strong>, <strong><code>embed_dim</code></strong>) :: <code>Module</code></p>
</blockquote>
<p>Base class for all neural network modules.</p>
<p>Your models should also subclass this class.</p>
<p>Modules can also contain other Modules, allowing to nest them in
a tree structure. You can assign the submodules as regular attributes::</p>

<pre><code>import torch.nn as nn
import torch.nn.functional as F

class Model(nn.Module):
    def __init__(self):
        super(Model, self).__init__()
        self.conv1 = nn.Conv2d(1, 20, 5)
        self.conv2 = nn.Conv2d(20, 20, 5)

    def forward(self, x):
        x = F.relu(self.conv1(x))
        return F.relu(self.conv2(x))

</code></pre>
<p>Submodules assigned in this way will be registered, and will have their
parameters converted too when you call :meth:<code>to</code>, etc.</p>
<p>:ivar training: Boolean represents whether this module is in training or
                evaluation mode.
:vartype training: bool</p>

</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="FNFM" class="doc_header"><code>class</code> <code>FNFM</code><a href="https://github.com/RecoHut-Projects/recohut/tree/master/recohut/models/fnfm.py#L37" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>FNFM</code>(<strong><code>field_dims</code></strong>, <strong><code>embed_dim</code></strong>, <strong><code>mlp_dims</code></strong>, <strong><code>dropouts</code></strong>) :: <code>Module</code></p>
</blockquote>
<p>A pytorch implementation of Field-aware Neural Factorization Machine.
Reference:
    L Zhang, et al. Field-aware Neural Factorization Machine for Click-Through Rate Prediction, 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>- L Zhang, et al. Field-aware Neural Factorization Machine for Click-Through Rate Prediction, 2019.</p>
<ul>
<li><a href="https://github.com/rixwew/pytorch-fm/blob/master/torchfm/model/fnfm.py">https://github.com/rixwew/pytorch-fm/blob/master/torchfm/model/fnfm.py</a></li>
</ul>
</blockquote>

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

