本文整理汇总了Python中NeuralNetwork.NeuralNetwork.guess方法的典型用法代码示例。如果您正苦于以下问题:Python NeuralNetwork.guess方法的具体用法?Python NeuralNetwork.guess怎么用?Python NeuralNetwork.guess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NeuralNetwork.NeuralNetwork
的用法示例。
在下文中一共展示了NeuralNetwork.guess方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: from NeuralNetwork import NeuralNetwork [as 别名]
# 或者: from NeuralNetwork.NeuralNetwork import guess [as 别名]
s_in.append([t/100])
s_teach.append([n.sin(n.pi*t/100)])
s_in = n.array(s_in)
s_teach = n.array(s_teach)
nn.teach(s_in, s_teach ,0.02,50000) # Trainiren:
# Anzeige:
t = n.arange(-2.0, 2.0, 0.05)
nnPlot = []
for _t in t:
nnPlot.append(nn.guess(_t)[-1][-1])
l1, = plt.plot(t, n.sin(n.pi*t))
l2, = plt.plot(t, nnPlot)
plt.legend( (l1, l2), ('n.sin(t)', 'nn.guess(t)'), loc='upper right', shadow=True)
plt.xlabel('t')
plt.title('Vergleich')
plt.show()
示例2: NeuralNetwork
# 需要导入模块: from NeuralNetwork import NeuralNetwork [as 别名]
# 或者: from NeuralNetwork.NeuralNetwork import guess [as 别名]
nn = NeuralNetwork([2,2,4,2,1]) # Erstelle neues Neurales Netzwerk mit 2 Eingangsneuronen, 6 Hidden-Neuronen und 1 Ausgangsneuronen.
# Möglich wäre auch: NeuralNetwork([2,6,7,3,1]) also mit mehren Hidden Layern!
s_in = n.array([[0, 0], [0, 1], [1, 0], [1, 1]]) #Trainingsdaten Input
s_teach = n.array([[0], [1], [1], [0]]) #Trainingsdaten Output
#s_teach = n.array([[0,0], [1,1], [1,1], [0,0]]) #Trainingsdaten Output
mysp.record('start')
nn.teach(s_in, s_teach ,0.2,50000) # Trainiren:
mysp.record('ende')
mysp.printRecords()
#s_in: Input Daten als numpy-Array
#s_teach: Output Daten als numpy-Array
# optional: epsilon=0.2: Lernfaktor
# optional: repeats=10000: Wiederholungen
for i in [[0, 0], [0, 1], [1, 0], [1,1]]:
print(i,nn.guess(i))
# whoaaaa: sichern von Daten zum laden fürs nächste Mal ;)
#nn.save('savetest') # erzeugt eine 'savetest.npz' Datei! (alles unchecked!, überschreiben ohne Warnung!)
#nn.load('savetest') # läd eine 'savetest.npz' Datei! (alles unchecked!)
示例3: open
# 需要导入模块: from NeuralNetwork import NeuralNetwork [as 别名]
# 或者: from NeuralNetwork.NeuralNetwork import guess [as 别名]
f = open('bla.txt','w')
#f.write(str(s_in))
for i in s_in:
f.write(str(i) + "nnn")
f.write(str(i.shape))
f.close()
from NeuralNetwork import NeuralNetwork
nn = NeuralNetwork([64,40,6])
nn.teach(n.array(s_in), n.array(s_teach) ,0.03,25000) # Trainiren:
#nn.teach(s_in, s_teach ,0.3,25000) # Trainiren:
print('char / char (bin) / NN output (bin) / NN output (raw)')
for i in [3, 7, 9, 14, 25]:
dataout = nn.guess(s_in[i])
print(data[1][i], s_teach[i] , n.around(dataout) , dataout)
# whoaaaa: sichern von Daten zum laden fürs nächste Mal ;)
#nn.save('savetest') # erzeugt eine 'savetest.npz' Datei! (alles unchecked!, überschreiben ohne Warnung!)
#nn.load('savetest') # läd eine 'savetest.npz' Datei! (alles unchecked!)