Are you sure you want to delete this access key?
Legend |
---|
DVC Managed File |
Git Managed File |
Metric |
Stage File |
External File |
Legend |
---|
DVC Managed File |
Git Managed File |
Metric |
Stage File |
External File |
Data preprocessing:
data = pd.read_csv(file_path) # Load CSV data
scaler = MinMaxScaler()
columns_to_normalize = ['position x [m]', 'position y [m]', 'position z (height) [m]', 'velocity [m/s]']
data[columns_to_normalize] = scaler.fit_transform(data[columns_to_normalize])
positions = data[['position x [m]', 'position y [m]', 'position z (height) [m]']].values
velocities = data['velocity [m/s]'].values
Model training:
def train_irl_with_dataset(self, data, lr=0.001, epochs=3):
state_dim = self.state_dim
optimizer = tf.keras.optimizers.Adam(learning_rate=lr)
positions = data[['position x [m]', 'position y [m]', 'position z (height) [m]']].values
velocities = data['velocity [m/s]'].values
mlflow.tensorflow.autolog()
with mlflow.start_run(experiment_id=get_or_create_experiment_id("Base Reproduction")):
for epoch in range(epochs):
total_loss = 0
state_frequencies = self._calculate_state_frequencies(positions)
for idx in range(len(positions)):
state = positions[idx]
velocity = velocities[idx]
with tf.GradientTape() as tape:
preferences = self.model(state[np.newaxis, :])
prob_human = tf.nn.softmax(preferences)
# Define losses
max_entropy_loss = -tf.reduce_sum(prob_human * tf.math.log(prob_human + 1e-8), axis=1)
alignment_loss = -tf.reduce_sum(state_frequencies * tf.math.log(prob_human + 1e-8), axis=1)
maxent_irl_objective = max_entropy_loss + alignment_loss
# Compute the gradients
grads = tape.gradient(maxent_irl_objective, self.model.trainable_variables)
optimizer.apply_gradients(zip(grads, self.model.trainable_variables))
total_loss += tf.reduce_sum(maxent_irl_objective) # Accumulate the total loss
avg_loss = total_loss / len(positions)
mlflow.log_metric(f"loss", avg_loss, step=epoch)
print(f"Epoch {epoch + 1}/{epochs}, MaxEnt IRL Loss: {avg_loss}")
Outputs: https://dagshub.com/ML-Purdue/hackathonf23-Stacks/experiments/#/
Environment Software package documentation located in: requirements.txt The model was trained and tested on a 2018 MacBook Pro, with an Intel i7 chip, an Intel UHD Graphics 630 GPU, along with a Radeon Pro 560X discrete GPU from AMD with 4GB of GDDR5 memory
Evaluation
To evaluate the BASE reproduction:
open 'reproduced_model_runner.py' and change the following directories:
"test_data_path = '/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/data/test.csv'" and
"model_path = '/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/models/reproduced_model.pkl'"
to:
"test_data_path = '/your/path/to/our/local/repository/hackathonf23-Stacks/data/test.csv'" and
"model_path = '/your/path/to/our/local/repository/hackathonf23-Stacks/models/reproduced_model.pkl'" respectively.
then, run 'python3 reproduced_model_runner'
To evaluate the Removed Hidden Layer reproduction:
open 'removed_hidden_layer_runner.py' and change the following directories:
"test_data_path = '/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/data/test.csv'" and
"model_path = '/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/models/reproduced_model.pkl'"
to:
"test_data_path = '/your/path/to/our/local/repository/hackathonf23-Stacks/data/test.csv'" and
"model_path = '/your/path/to/our/local/repository/hackathonf23-Stacks/models/removed_hidden_layer.pkl'" respectively.
then, run 'python3 removed_hidden_layer_runner.py'
To evaluate the Removed Maximum Entropy reproduction:
open 'rmv_max_entropy_runner.py' and change the following directories:
"test_data_path = '/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/data/test.csv'" and
"model_path = '/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/models/reproduced_model.pkl'"
to:
"test_data_path = '/your/path/to/our/local/repository/hackathonf23-Stacks/data/test.csv'" and
"model_path = '/your/path/to/our/local/repository/hackathonf23-Stacks/models/rmv_max_entropy_model.pkl'" respectively.
then, run 'python3 rmv_max_entropy_runner.py'
To evaluate the Removed Discount Factor reproduction:
open 'rmv_discount_runner.py' and change the following directories:
"test_data_path = '/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/data/test.csv'" and
"model_path = '/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/models/reproduced_model.pkl'"
to:
"test_data_path = '/your/path/to/our/local/repository/hackathonf23-Stacks/data/test.csv'" and
"model_path = '/your/path/to/our/local/repository/hackathonf23-Stacks/models/rmv_discount_model.pkl'" respectively.
then, run 'python3 rmv_discount_runner.py'
To evaluate the Removed State Dimension reproduction:
open 'rmv_dimension_runner.py' and change the following directories:
"test_data_path = '/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/data/test.csv'" and
"model_path = '/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/models/reproduced_model.pkl'"
to:
"test_data_path = '/your/path/to/our/local/repository/hackathonf23-Stacks/data/test.csv'" and
"model_path = '/your/path/to/our/local/repository/hackathonf23-Stacks/models/rmv_dim_model.pkl'" respectively.
then, run 'python3 rmv_dimension_runner.py'
To evaluate the Removed Leaky ReLU reproduction:
open 'leaky_relu_runner.py' and change the following directories:
"test_data_path = '/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/data/test.csv'" and
"model_path = '/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/models/reproduced_model.pkl'"
to:
"test_data_path = '/your/path/to/our/local/repository/hackathonf23-Stacks/data/test.csv'" and
"model_path = '/your/path/to/our/local/repository/hackathonf23-Stacks/models/leaky_relu_model.pkl'" respectively.
then, run 'python3 leaky_relu_runner.py'
To re-train the BASE reproduction:
open 'reproduced_model.py' and change the following directories:
"file_path = '/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/data/train.csv'" and
"irl.save_model('/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/models/reproduced_model.pkl')"
to:
"file_path = '/your/path/to/our/local/repository/hackathonf23-Stacks/data/train.csv'" and
"irl.save_model('/your/path/to/our/local/repository/hackathonf23-Stacks/models/reproduced_model.pkl')'" respectively.
then, run 'python3 reproduced_model.py'
To re-train the Removed Hidden Layer Ablation:
open 'removed_hidden_layer.py' and change the following directories:
"file_path = '/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/data/train.csv'" and
"irl.save_model('/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/models/reproduced_model.pkl')"
to:
"file_path = '/your/path/to/our/local/repository/hackathonf23-Stacks/data/train.csv'" and
"irl.save_model('/your/path/to/our/local/repository/hackathonf23-Stacks/models/removed_hidden_layer.pkl')'" respectively.
then, run 'python3 removed_hidden_layer.py'
To re-train the Removed Max Entropy Ablation:
open 'rmv_max_entropy_local.py' and change the following directories:
"file_path = '/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/data/train.csv'" and
"irl.save_model('/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/models/reproduced_model.pkl')"
to:
"file_path = '/your/path/to/our/local/repository/hackathonf23-Stacks/data/train.csv'" and
"irl.save_model('/your/path/to/our/local/repository/hackathonf23-Stacks/models/rmv_max_entropy_model.pkl')'" respectively.
then, run 'python3 rmv_max_entropy_local.py'
To re-train the Removed Discount Factor Ablation:
open 'rmv_discount_local.py' and change the following directories:
"file_path = '/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/data/train.csv'" and
"irl.save_model('/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/models/reproduced_model.pkl')"
to:
"file_path = '/your/path/to/our/local/repository/hackathonf23-Stacks/data/train.csv'" and
"irl.save_model('/your/path/to/our/local/repository/hackathonf23-Stacks/models/rmv_discount_model.pkl')'" respectively.
then, run 'python3 rmv_discount_local.py'
To re-train the Removed State Dimension Ablation:
open 'rmv_dim.py' and change the following directories:
"file_path = '/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/data/train.csv'" and
"irl.save_model('/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/models/reproduced_model.pkl')"
to:
"file_path = '/your/path/to/our/local/repository/hackathonf23-Stacks/data/train.csv'" and
"irl.save_model('/your/path/to/our/local/repository/hackathonf23-Stacks/models/rmv_dim_model.pkl')'" respectively.
then, run 'python3 rmv_dim.py'
To re-train the Leaky ReLU Ablation:
open 'leaky_relu_local.py' and change the following directories:
"file_path = '/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/data/train.csv'" and
"irl.save_model('/Users/vinay/Desktop/Computer_Science_Projects/ReScience/hackathonf23-Stacks/models/leaky_relu_model.pkl')"
to:
"file_path = '/your/path/to/our/local/repository/hackathonf23-Stacks/data/train.csv'" and
"irl.save_model('/your/path/to/our/local/repository/hackathonf23-Stacks/models/reproduced_model.pkl')'" respectively.
then, run 'python3 leaky_relu_local.py'
Press p or to see the previous file or, n or to see the next file
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?