1 Star 0 Fork 0

jessssy_yang/Deep-Learning-in-Python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Feed_Forward.py 1.06 KB
一键复制 编辑 原始数据 按行查看 历史
'''This helps in predicting no. of transaction when a customer has 'x' no. of children and
'y' no. of bank accounts for four customers.'''
import numpy as np
#input_data = [#_of_children, #_of_accounts] for 4 customers
input_data = [np.array([3, 5]), np.array([ 1, -1]), np.array([0, 0]), np.array([8, 4])]
weights = {'node_0': np.array([2, 4]), 'node_1': np.array([ 4, -5]), 'output': np.array([2, 7])}
def relu(input):
output = max(0, input)
return output
def predict_with_network(input_data_row, weights):
node_0_input = (input_data_row * weights['node_0']).sum()
node_0_output = relu(node_0_input)
node_1_input = (input_data_row * weights['node_1']).sum()
node_1_output = relu(node_1_input)
hidden_layer_outputs = np.array([node_0_output, node_1_output])
input_to_final_layer = (hidden_layer_outputs * weights['output']).sum()
model_output = relu(input_to_final_layer)
return model_output
results = []
for input_data_row in input_data:
results.append(predict_with_network(input_data_row, weights))
print(results)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jessssy_yang/Deep-Learning-in-Python.git
git@gitee.com:jessssy_yang/Deep-Learning-in-Python.git
jessssy_yang
Deep-Learning-in-Python
Deep-Learning-in-Python
master

搜索帮助