Skip to content

Commit

Permalink
style: format code with Autopep8, Black, ClangFormat, dotnet-format, …
Browse files Browse the repository at this point in the history
…Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf

This commit fixes the style issues introduced in 918e5b0 according to the output
from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java
Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt,
Scalafmt, StandardJS, StandardRB, swift-format and Yapf.

Details: None
  • Loading branch information
deepsource-autofix[bot] authored May 11, 2024
1 parent 918e5b0 commit 52b2a2e
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions models/ai_models/neural_networks.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Import necessary libraries
import tensorflow as tf
from tensorflow import keras
from sklearn.preprocessing import StandardScaler
from tensorflow import keras

# Define a class for neural networks


class NeuralNetwork:
def __init__(self, input_shape, output_shape, hidden_layers):
self.input_shape = input_shape
Expand All @@ -16,14 +18,22 @@ def _create_model(self):
model = keras.Sequential()
model.add(keras.layers.InputLayer(input_shape=self.input_shape))
for layer in self.hidden_layers:
model.add(keras.layers.Dense(layer, activation='relu'))
model.add(keras.layers.Dense(self.output_shape, activation='softmax'))
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])
model.add(keras.layers.Dense(layer, activation="relu"))
model.add(keras.layers.Dense(self.output_shape, activation="softmax"))
model.compile(
optimizer="adam", loss="categorical_crossentropy", metrics=["accuracy"]
)
return model

def train(self, X_train, y_train, X_test, y_test):
# Train the neural network model
self.model.fit(X_train, y_train, epochs=10, batch_size=128, validation_data=(X_test, y_test))
self.model.fit(
X_train,
y_train,
epochs=10,
batch_size=128,
validation_data=(X_test, y_test),
)

def predict(self, X):
# Make predictions using the trained model
Expand All @@ -34,7 +44,10 @@ def evaluate(self, X_test, y_test):
loss, accuracy = self.model.evaluate(X_test, y_test)
return accuracy


# Define a function to load a neural network model


def load_neural_network(model_path):
# Load the neural network model from a file
model = tf.keras.models.load_model(model_path)
Expand Down

0 comments on commit 52b2a2e

Please sign in to comment.