@Pigmon
2018-08-30T04:39:40.000000Z
字数 565
阅读 1201
作业
# -*- coding: utf-8 -*-"""Udacity Lesson day2Sigmoid funcDay2-1 Yuan Sheng"""import numpy as npimport matplotlib.pyplot as pltdef 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 npdef sum(_x1, _w1, _x2, _w2, _b, _w3):return _x1 * _w1 + _x2 * _w2 + _b * _w3def 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, 1print (fun(sum(x1, w1, x2, w2, b, w3)))
