简体   繁体   English

使用向量进行深度学习

[英]Deep Learning using vector

I've built a network with no hidden layer.我已经建立了一个没有隐藏层的网络。 As shown below, I'm using an Activation function with Sigmoid and an Error function with MSE.如下所示,我正在使用带有 Sigmoid 的激活 function 和带有 MSE 的错误 function。 Dataset used is the Titanic dataset from Kaggle and I have pre-processed the data.使用的数据集是来自 Kaggle 的 Titanic 数据集,我已经对数据进行了预处理。
The Error function of the model keeps on increasing. model的错误function不断增加。 How can I update the weights properly to reduce the Error function?如何正确更新权重以减少错误 function? I am a beginner.我是初学者。 Please bear with me.请多多包涵。

Link for the dataset:数据集链接:
https://drive.google.com/file/d/1RZjCvJ732uHx-IAlhPAVRHDwabYsHJJl/view?usp=sharing https://drive.google.com/file/d/1RZjCvJ732uHx-IAlhPAVRHDwabYsHJJl/view?usp=sharing

My colab notebook:我的 colab 笔记本:
https://colab.research.google.com/drive/1HD9RA1RXQcaBvUANz3vR_6iW0BSr9kDp?usp=sharing https://colab.research.google.com/drive/1HD9RA1RXQcaBvUANz3vR_6iW0BSr9kDp?usp=sharing

import numpy as np
X=np.array(td.drop(columns=['Survived','Fare'],axis=1))
Y=np.array(td['Survived'])
X=X.T
print('X shape :',X.shape)
print('Y shape :',Y.shape)
W=np.zeros((nf,1))
print('W shape :',W.shape)
B=0
for _ in range(100):
  z=summation(W,X,B)
  print("shape of z : ",z.shape)
  # print('z = ',z)
  y=sigmoid(z.T)
  # print(' y = ',y)
  cost=(error(Y,y))/ne
  print('cost = ',cost)
  updatefactor=((Y-y)*(Y-1))*y*(1-y)*X/ne
  print(updatefactor.squeeze())
  # print('updatefactor : ',updatefactor)
  # print('*****************************')
  print(updatefactor.shape)
  W=updW(W,0.001,updatefactor)

I assume you are building a perceptron model.我假设您正在构建一个感知器 model。

as @Rahul Vishwakarma commented, in calculated z value, you need to multiply weights, W and features, X together and add the bias, B. Just summationing these three terms would not lead to a proper activation.正如@Rahul Vishwakarma 评论的那样,在计算出的 z 值中,您需要将权重 W 和特征 X 相乘并加上偏差 B。仅将这三个项相加不会导致正确的激活。 So, you could do something like所以,你可以做类似的事情

z = np.dot(W,X) + B

Make sure W and X are aligned for vector multiplication.确保 W 和 X 对齐以进行向量乘法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM