@Pigmon
2018-08-30T12:39:40.000000Z
字数 565
阅读 923
作业
# -*- coding: utf-8 -*-
"""
Udacity Lesson day2
Sigmoid func
Day2-1 Yuan Sheng
"""
import numpy as np
import matplotlib.pyplot as plt
def sigmoid(x):
"Sigmoid(x) = 1 / (1 + e^{-x})"
return 1. / (1. + np.e ** (-x))
if __name__ == '__main__':
# Plot sigmoid[-6, 6]
x = np.linspace(-6, 6, 50)
plt.plot(x, sigmoid(x))
plt.show()
输出:
答案: y = 1.0
# -*- coding: utf-8 -*-
import numpy as np
def sum(_x1, _w1, _x2, _w2, _b, _w3):
return _x1 * _w1 + _x2 * _w2 + _b * _w3
def fun(x):
"Sigmoid(x) = 1 / (1 + e^{-x})"
return 1. / (1. + np.e ** (-x))
if __name__ == '__main__':
x1, x2, b, w1, w2, w3 = 7, -3, 0, 7, 6, 1
print (fun(sum(x1, w1, x2, w2, b, w3)))