this is my first deep neural network and I have a problem in this code while implementing it. beside the error the code is slow and it is another thing.
Here is the 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]))
Here is the error
> 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'