55
66[ ![ Build Status] ( https://travis-ci.org/jrzaurin/pytorch-widedeep.svg?branch=master )] ( https://travis-ci.org/jrzaurin/pytorch-widedeep )
77[ ![ Documentation Status] ( https://readthedocs.org/projects/pytorch-widedeep/badge/?version=latest )] ( https://pytorch-widedeep.readthedocs.io/en/latest/?badge=latest )
8+ [ ![ Maintenance] ( https://img.shields.io/badge/Maintained%3F-yes-green.svg )] ( https://github.com/jrzaurin/pytorch-widedeep/graphs/commit-activity )
9+
10+ Platform | Version Support
11+ ---------|:---------------
12+ OSX | [ ![ Python 3.6 3.7] ( https://img.shields.io/badge/python-3.6%20%203.7-blue.svg )] ( https://www.python.org/ )
13+ Linux | [ ![ Python 3.6 3.7 3.8] ( https://img.shields.io/badge/python-3.6%20%203.7%203.8-blue.svg )] ( https://www.python.org/ )
814
915# pytorch-widedeep
1016
@@ -34,11 +40,11 @@ few lines of code.
3440 <img width =" 600 " src =" docs/figures/architecture_1.png " >
3541</p >
3642
37- Architecture 1 combines the ` Wide ` , one-hot encoded features with the outputs
38- from the ` DeepDense ` , ` DeepText ` and ` DeepImage ` components connected to a
39- final output neuron or neurons, depending on whether we are performing a
40- binary classification or regression, or a multi-class classification. The
41- components within the faded-pink rectangles are concatenated.
43+ Architecture 1 combines the ` Wide ` , Linear model with the outputs from the
44+ ` DeepDense ` , ` DeepText ` and ` DeepImage ` components connected to a final output
45+ neuron or neurons, depending on whether we are performing a binary
46+ classification or regression, or a multi-class classification. The components
47+ within the faded-pink rectangles are concatenated.
4248
4349In math terms, and following the notation in the
4450[ paper] ( https://arxiv.org/abs/1606.07792 ) , Architecture 1 can be formulated
@@ -65,10 +71,10 @@ otherwise".*
6571 <img width =" 600 " src =" docs/figures/architecture_2.png " >
6672</p >
6773
68- Architecture 2 combines the ` Wide ` one-hot encoded features with the Deep
69- components of the model connected to the output neuron(s), after the different
70- Deep components have been themselves combined through a FC-Head (that I refer
71- as ` deephead ` ).
74+ Architecture 2 combines the ` Wide ` , Linear model with the Deep components of
75+ the model connected to the output neuron(s), after the different Deep
76+ components have been themselves combined through a FC-Head (that I refer as
77+ ` deephead ` ).
7278
7379In math terms, and following the notation in the
7480[ paper] ( https://arxiv.org/abs/1606.07792 ) , Architecture 2 can be formulated
@@ -84,7 +90,8 @@ and `DeepImage` are optional. `pytorch-widedeep` includes standard text (stack
8490of LSTMs) and image (pre-trained ResNets or stack of CNNs) models. However,
8591the user can use any custom model as long as it has an attribute called
8692` output_dim ` with the size of the last layer of activations, so that
87- ` WideDeep ` can be constructed. See the examples folder for more information.
93+ ` WideDeep ` can be constructed. See the examples folder or the docs for more
94+ information.
8895
8996
9097### Installation
@@ -112,14 +119,6 @@ cd pytorch-widedeep
112119pip install -e .
113120```
114121
115- ### Examples
116-
117- There are a number of notebooks in the ` examples ` folder plus some additional
118- files. These notebooks cover most of the utilities of this package and can
119- also act as documentation. In the case that github does not render the
120- notebooks, or it renders them missing some parts, they are saved as markdown
121- files in the ` docs ` folder.
122-
123122### Quick start
124123
125124Binary classification with the [ adult
@@ -128,6 +127,7 @@ using `Wide` and `DeepDense` and defaults settings.
128127
129128``` python
130129import pandas as pd
130+ import numpy as np
131131from sklearn.model_selection import train_test_split
132132
133133from pytorch_widedeep.preprocessing import WidePreprocessor, DensePreprocessor
@@ -166,7 +166,7 @@ target = df_train[target_col].values
166166# wide
167167preprocess_wide = WidePreprocessor(wide_cols = wide_cols, crossed_cols = cross_cols)
168168X_wide = preprocess_wide.fit_transform(df_train)
169- wide = Wide(wide_dim = X_wide.shape[1 ], pred_dim = 1 )
169+ wide = Wide(wide_dim = np.unique( X_wide) .shape[0 ], pred_dim = 1 )
170170
171171# deepdense
172172preprocess_deep = DensePreprocessor(embed_cols = embed_cols, continuous_cols = cont_cols)
0 commit comments