# Titanic - Neural Network - Two hidden layers – 5 units ReLU and 3 units tanh

**URL:** <https://discuss.pytorch.org/t/titanic-neural-network-two-hidden-layers-5-units-relu-and-3-units-tanh/148761>\
**Category:** ignite\
**Created:** [April 10, 2022, 7:10pm UTC](https://discuss.pytorch.org/t/titanic-neural-network-two-hidden-layers-5-units-relu-and-3-units-tanh/148761 "2022-04-10T19:10:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dipakpatadia](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/dipakpatadia/32/48486_2.png) [@dipakpatadia](https://discuss.pytorch.org/u/dipakpatadia)\
**Post date:** [April 10, 2022, 7:10pm UTC](https://discuss.pytorch.org/t/titanic-neural-network-two-hidden-layers-5-units-relu-and-3-units-tanh/148761/1 "2022-04-10T19:10:33Z")

</div>

Want to build a model neural network model using **PyTorch** library.

The model should use two hidden layers: the first hidden layer must contain **5 units using the ReLU** activation function; the second layer must contain **3 units using tanh** activation function.

Want to use the Titanic train dataset I have. Want to use ONLY the train dataset (.CVV) and split the dataset (i.e., train.csv) to a training set (80% samples) and a testing set  
(20% samples)

Don’t know how to define model definition for 2 hidden layers which are ReLU and tanh with 5 and 3 units (nucleus) respectively.

A sample code would really help. Step by step code including standard methods implemented (data cleansing, normalizing, Model training, testing, etc.) would really help me to learn this.

I am using a Jupyter notebook.

Regards,  
Dipak

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [April 10, 2022, 8:52pm UTC](https://discuss.pytorch.org/t/titanic-neural-network-two-hidden-layers-5-units-relu-and-3-units-tanh/148761/2 "2022-04-10T20:52:12Z")

</div>

The [CIFAR10 tutorial](https://pytorch.org/tutorials/beginner/blitz/cifar10_tutorial.html) might be a good starter as it walks you through the data loading pipeline, defining a custom model, and training it.

---

<div class="post-metadata">

**Author:** ![dipakpatadia](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/dipakpatadia/32/48486_2.png) [@dipakpatadia](https://discuss.pytorch.org/u/dipakpatadia)\
**Post date:** [April 11, 2022, 3:46am UTC](https://discuss.pytorch.org/t/titanic-neural-network-two-hidden-layers-5-units-relu-and-3-units-tanh/148761/3 "2022-04-11T03:46:38Z")

</div>

Thank you so much for referring good start.

---

<div class="post-metadata">

**Author:** ![dipakpatadia](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/dipakpatadia/32/48486_2.png) [@dipakpatadia](https://discuss.pytorch.org/u/dipakpatadia)\
**Post date:** [April 13, 2022, 7:48am UTC](https://discuss.pytorch.org/t/titanic-neural-network-two-hidden-layers-5-units-relu-and-3-units-tanh/148761/4 "2022-04-13T07:48:45Z")

</div>

I am getting the below error. How this can be resolved?

# Lets Split the Train Dataset into training set (80%) and Testing set (20%)

X = train.drop(‘Survived’, axis=1).values  
y = train[‘Survived’].values

X\_train, X\_test, y\_train, y\_test = train\_test\_split(X, y, test\_size=0.2, random\_state=42)

X\_train = torch.FloatTensor(X\_train)  
X\_test = torch.FloatTensor(X\_test)  
y\_train = torch.LongTensor(y\_train)  
y\_test = torch.LongTensor(y\_test)

TypeError Traceback (most recent call last)  
C:\Users\JAYPAT~1\AppData\Local\Temp/ipykernel\_5072/502746771.py in   
6 X\_train, X\_test, y\_train, y\_test = train\_test\_split(X, y, test\_size=0.2, random\_state=42)  
7  
----\> 8 X\_train = torch.FloatTensor(X\_train)  
9 X\_test = torch.FloatTensor(X\_test)  
10 y\_train = torch.LongTensor(y\_train)

TypeError: can’t convert np.ndarray of type numpy.object\_. The only supported types are: float64, float32, float16, complex64, complex128, int64, int32, int16, int8, uint8, and bool.
