Advertisement
roachsinai

Untitled

Dec 1st, 2021
977
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. import pandas as pd
  2. from tensorflow.keras import Sequential
  3. from tensorflow.keras.layers import Dense
  4. from tensorflow.keras.optimizers import SGD
  5.  
  6. x_file = "X.csv"
  7. y_file = "Y.csv"
  8.  
  9. X = pd.read_csv(x_file, sep=",", header=None)
  10. X = X.values.T
  11. normalized_X = (X - X.mean()) / X.std()
  12.  
  13. Y = pd.read_csv(y_file, sep=",", header=None)
  14. Y = Y.values
  15.  
  16. # %%
  17. model = Sequential()
  18. model.add(Dense(units=1024, activation="relu", input_dim=20530))
  19. model.add(Dense(units=50, activation="relu"))
  20. model.add(Dense(units=1, activation="sigmoid"))
  21.  
  22. sgd = SGD(learning_rate=0.001)
  23. model.compile(loss="binary_crossentropy", optimizer=sgd, metrics=["accuracy"])
  24. model.fit(normalized_X, Y, batch_size=1, epochs=50)
  25.  
  26. Y_pred = model.predict(normalized_X)
  27. sum(Y_pred > .5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement