Home > other >  Run the model fit () a TypeError: float () argument must be a string or a number
Run the model fit () a TypeError: float () argument must be a string or a number

Time:12-21

What a great god can help me have a look at why I just examples of modeled on the Internet made a keras neural network training, and then the model. (where) the fit so TypeError: float () argument must be a string or a number, not 'method' mistakes,
Here is my code
 
The from scipy. IO import arff
The import pandas as pd
Data, meta=arff. Loadarff ("./data/1 year. Arff ")
Df=pd DataFrame (data)
Print (df) head ())

Df. Fillna (df) scheme, inplace=True)
Print (df) scheme)
Print (df) isnull (). The sum ())

# training set separation test set
X=df. Iloc [: : 64]
Y=df. Iloc [:, 64]
The from sklearn. Model_selection import train_test_split
X_train X_test, y_train, y_test=train_test_split (X, y, test_size=0.30, random_state=1)
Print (X_train)
Print (X_test)
Print (y_train)
Print (y_test)

The from keras. The layers import Dense, Dropout, Input
The from keras. Models import Model, Sequential

The model=Sequential ()
Model. The add (Dense (32, input_dim=64, activation="relu"))
Model. The add (Dense (16, activation="relu"))
Model. The add (Dense (8, activation="relu"))
Model. The add (Dense (4, activation="relu"))
Model. The add (Dense (2, activation="relu"))
Model. The add (Dense (1, the activation="softmax"))
Model.com from running (loss="binary_crossentropy", the optimizer="Adam", the metrics=[' accuracy '])
Model. The summary ()
The model fit (X_train y_train, batch_size=300, epochs=20) # error in this line
Accuracy=model. The evaluate (X_test y_test)
Print (accuracy)


An error message here

Error message text summary
 
TypeError Traceback (the most recent call last)


11 model.com running (loss="binary_crossentropy", optimizer="Adam", the metrics=[' accuracy '])
12 model. The summary ()
- & gt; 13. The model fit (X_train y_train, batch_size=300, epochs=20)
14 accuracy=model. The evaluate (X_test y_test)
15 print (accuracy)

C: \ users \ \ appdata \ 86176 local \ designed \ python \ python38 \ lib \ site - packages \ keras \ engine \ training py fit in (self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, max_queue_size, workers, use_multiprocessing, * * kwargs)
1225
1226 # Delegate logic to ` fit_loop `.
-> 1227 return training_arrays. Fit_loop (self, fit_function, fit_inputs,
1228 out_labels=out_labels,
1229 batch_size=batch_size,

C: \ users \ \ appdata \ 86176 local \ designed \ python \ python38 \ lib \ site - packages \ keras \ engine \ training_arrays py in fit_loop (model, fit_function, fit_inputs out_labels, batch_size, epochs, verbose, callbacks, val_function, val_inputs, shuffle, initial_epoch, steps_per_epoch, validation_steps, validation_freq)
194 ins_batch [I]=ins_batch [I] toarray ()
195
- & gt; 196 outs=fit_function (ins_batch)
197 outs=to_list (outs)
For 198 l, o in zip (out_labels, outs) :

TypeError: float () argument must be a string or a number, not 'method'



Df. Head () results the following

Save the children
  • Related