Sion
Sion

Reputation: 36

Tensorflow/Keras Type Error about compile

I import

from tensorflow.keras.layers import Activation, Dense, Dropout
from tensorflow.keras.models import Sequential
from tensorflow.keras.callbacks import EarlyStopping
from tensorflow.keras import optimizers
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

these and at this part,

model.compile(loss='binary_crossentropy', optimizer='adam'(lr=0.001), metrics=['acc'])

like this Type error was occurred

TypeError                                 Traceback (most recent call last)
<ipython-input-82-d2bcad9a50e3> in <module>
----> 1 model.compile(loss='binary_crossentropy', optimizer='adam'(lr=0.001), metrics=['acc'])

TypeError: 'str' object is not callable

I found it on google, but I could not find a solution... Does anyone know why this error is occurred? Thank you for reading.

Upvotes: 0

Views: 123

Answers (1)

Reza
Reza

Reputation: 2035

change it to this:

opt = optimizers.Adam(learning_rate=0.001)
model.compile(loss='binary_crossentropy', optimizer=opt, metrics=['accuracy'])

Upvotes: 1

Related Questions