Tuesday, February 12, 2019

Simple Neural Network in Python

透過下列連結, 可以執行簡單的 Python 類神經網路程式:

https://medium.com/technology-invention-and-more/how-to-build-a-simple-neural-network-in-9-lines-of-python-code-cc8f23647ca1

from numpy import exp, array, random, dot
training_set_inputs = array([[0, 0, 1], [1, 1, 1], [1, 0, 1], [0, 1, 1]])
training_set_outputs = array([[0, 1, 1, 0]]).T
random.seed(1)
synaptic_weights = 2 * random.random((3, 1)) - 1
for iteration in range(1000):
    output = 1 / (1 + exp(-(dot(training_set_inputs, synaptic_weights))))
    synaptic_weights += dot(training_set_inputs.T, (training_set_outputs - output) * output * (1 - output))
print (1 / (1 + exp(-(dot(array([1, 0, 0]), synaptic_weights)))))
而此篇的另外一個重點為: 如何在 Google Blogger 中納入程式碼高亮顯示, 並且列出程式行號. 黨使用者登入 Google Blogger 後, View Blog 之右上方將會出現 Design 連結, 網誌管理者點選後, 可以進入 Theme, 並且選擇 Edit HTML, 將下列 Javascript 放在 head 標註中.

<script src='http://mde.tw/wcm2019/static/syntaxhighlighter/shCore.js' type='text/javascript'/>
<script src='http://mde.tw/wcm2019/static/syntaxhighlighter/shBrushCpp.js' type='text/javascript'/>
<script src='http://mde.tw/wcm2019/static/syntaxhighlighter/shBrushCSharp.js' type='text/javascript'/>
<script src='http://mde.tw/wcm2019/static/syntaxhighlighter/shBrushCss.js' type='text/javascript'/>
<script src='http://mde.tw/wcm2019/static/syntaxhighlighter/shBrushDelphi.js' type='text/javascript'/>
<script src='http://mde.tw/wcm2019/static/syntaxhighlighter/shBrushJava.js' type='text/javascript'/>
<script src='http://mde.tw/wcm2019/static/syntaxhighlighter/shBrushJScript.js' type='text/javascript'/>
<script src='http://mde.tw/wcm2019/static/syntaxhighlighter/shBrushPhp.js' type='text/javascript'/>
<script src='http://mde.tw/wcm2019/static/syntaxhighlighter/shBrushPython.js' type='text/javascript'/>
<script src='http://mde.tw/wcm2019/static/syntaxhighlighter/shBrushRuby.js' type='text/javascript'/>
<script src='http://mde.tw/wcm2019/static/syntaxhighlighter/shBrushSql.js' type='text/javascript'/>
<script src='http://mde.tw/wcm2019/static/syntaxhighlighter/shBrushVb.js' type='text/javascript'/>
<script src='http://mde.tw/wcm2019/static/syntaxhighlighter/shBrushXml.js' type='text/javascript'/>
<link href='http://mde.tw/wcm2019/static/syntaxhighlighter/css/shCoreDefault.css' rel='stylesheet' type='text/css'/>
<script type='text/javascript'>
SyntaxHighlighter.defaults['toolbar'] = false;
SyntaxHighlighter.all();
</script>

之後就可以透過 http://alexgorbatchev.com/SyntaxHighlighter/ 中的說明, 以 <pre class="brush: py"></pre> 或 <pre class="brush: js"></pre> 顯示對應的程式碼.

No comments:

Post a Comment

NX12

NX 12 Help https://docs.plm.automation.siemens.com/tdoc/nx/12/nx_help Python related https://docs.plm.automation.siemens.com/tdoc/nx/...