Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Equation-Chaleur/Eq-Chal-RNA.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import numpy as np
from keras.models import Sequential
from keras.layers import Dense

# Constants
dx = 0.1
dt = 0.01
alpha = 0.1

# Initialize the temperature grid
T = np.zeros((100, 100))
T[:, 0] = 100 # Left edge is 100 degrees
T[:, -1] = 0 # Right edge is 0 degrees

# Build the neural network model
model = Sequential()
model.add(Dense(100, input_shape=(100,), activation='relu'))
model.add(Dense(100, activation='relu'))
model.add(Dense(100))
model.compile(loss='mse', optimizer='adam')

# Iterate over time steps
for t in range(100):
# Compute the new temperature grid
T_new = np.zeros_like(T)
for i in range(1, 99):
for j in range(1, 99):
T_new[i, j] = T[i, j] + alpha * dt / dx**2 * (T[i+1, j] - 2*T[i, j] + T[i-1, j] + T[i, j+1] - 2*T[i, j] + T[i, j-1])

# Use the neural network to predict the temperature at the next time step
predictions = model.predict(T_new)

# Update the temperature grid with the predicted values
T = predictions
2 changes: 1 addition & 1 deletion RNA-Keras-Exemple/RNA-Keras-Ex2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Création du modèle de réseau de neurones en utilisant la bibliothèque Keras

model = Sequential()
model.add(Dense(4, input_dim=2, activation='relu'))
model.add(Dense(5, input_dim=2, activation='relu'))
model.add(Dense(1, activation='sigmoid'))

# Compilation et entraînement du modèle en utilisant l'algorithme de descente de gradient
Expand Down