Dies ist mein erstes tiefes neuronales Netzwerk und ich habe ein Problem in diesem Code während der Implementierung. neben dem Fehler ist der Code langsam und es ist eine andere Sache. Hiermein erstes tiefes Netzwerk
ist der Code:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
from keras.models import Sequential
from keras.layers import Dense
from keras.optimizers import SGD, Adam
from sklearn.datasets import make_moons
from sklearn.model_selection import train_test_split
x, y = make_moons(n_samples=1000, noise=0.1, random_state=0)
plt.plot(x[y == 0, 0], x[y == 0, 1], 'ob', alpha=0.5)
plt.plot(x[y == 1, 0], x[y == 1, 1], 'xr', alpha=0.5)
plt.legend(['0', '1'])
plt.show()
print(x.shape)
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=.3, random_state=42)
model = Sequential
model.add(Dense(1, input_shape=(2,), activation='sigmoid'))
model.compile(Adam(lr=0.5), 'binary_crossentropy', metrics=['accuracy'])
model.fit(x_train, y_train,epochs=200, verbose=0)
results = model.evaluate(x_test, y_test)
print('The Accuracy score on the Train set is:\t{:0.3f}'.format(results[1]))
Hier wird der Fehler
> Using TensorFlow backend. 2017-11-24 17:03:32.402292: W
> C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but
> these are available on your machine and could speed up CPU
> computations. 2017-11-24 17:03:32.402768: W
> C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but
> these are available on your machine and could speed up CPU
> computations. (1000, 2) Traceback (most recent call last): File
> "E:/Tutorial/Deep Learning.py", line 18, in <module>
> model.add(Dense(1, input_shape=(2,), activation='sigmoid')) TypeError: add() missing 1 required positional argument: 'layer'
Nun mit Matplotlib, müssen Sie 'plt.show()' zu starten, um die Ereignisschleife, die das Diagramm zeigt. Aber es scheint, dass Sie auch einige andere Fehler haben. – cchoe1
Der Fehler sagt Ihnen, was das Problem ist. Welcher Teil davon ist unerwartet? –
Die Fehlermeldung ist ziemlich klar, was das Problem ist. Hast du versucht es zu lösen? – mrCarnivore