Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel
9fd9893e8d
plotting error for each study based on validation data
1 year ago
eead7ad5e2
leaky relu model saving and loading correctly.
1 year ago
2bd2cfaf11
Added dvc
1 year ago
aa26806227
working saves and loads for reproduced model and removed hidden layer model
1 year ago
e83fecc372
Update 'README.md'
1 year ago
9ec37e5796
parameter yaml file
1 year ago
9fd9893e8d
plotting error for each study based on validation data
1 year ago
aa26806227
working saves and loads for reproduced model and removed hidden layer model
1 year ago
eead7ad5e2
leaky relu model saving and loading correctly.
1 year ago
1904f72325
final revisions of models
1 year ago
1 year ago
aa26806227
working saves and loads for reproduced model and removed hidden layer model
1 year ago
1904f72325
final revisions of models
1 year ago
aa26806227
working saves and loads for reproduced model and removed hidden layer model
1 year ago
1904f72325
final revisions of models
1 year ago
a4acd21f8f
requirements.txt
1 year ago
4c30419408
remove dimension model saving and morking correctly
1 year ago
1904f72325
final revisions of models
1 year ago
fda2d2daf6
removed discount factor model saving and loading properly
1 year ago
1904f72325
final revisions of models
1 year ago
ed9662856a
remove max entropy model saving and loading correctly
1 year ago
1904f72325
final revisions of models
1 year ago
Storage Buckets
Data Pipeline
Legend
DVC Managed File
Git Managed File
Metric
Stage File
External File

README.md

You have to be logged in to leave a comment. Sign In

hackathonf23-Stacks

  1. Runnable code for the project exists in the following project: https://dagshub.com/ML-Purdue/hackathonf23-Stacks The example input for our repo is located in this link: https://dagshub.com/ML-Purdue/hackathonf23-Stacks/src/main/data under train.csv.
  2. The following files include all relevant configuration parameters for the project: requirements.txt & config.yaml
  3. Data (+ Artifacts) All project data and artifacts can be found here: https://dagshub.com/ML-Purdue/hackathonf23-Stacks/src/main/data. The structure/schema of input data is the following: time [ms],person id,position x [m],position y [m],position z (height) [m],velocity [m/s],angle of motion [rad],facing angle [rad]

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/#/

  1. 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

  2. Evaluation

Instructions to Run Model Tests:

Instructions to test Base Reproduction

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'

Instructions to test Removed Hidden Layer Ablation

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'

Instructions to test Removed Maximum Entropy Ablation

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'

Instructions to test Removed Discount Factor Ablation

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'

Instructions to test Removed State Dimension Ablation

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'

Instructions to test Leaky ReLU Ablation

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'

Instructions to Retrain Models (not necessary to test, but if you chose to do so):

Instructions to re-train Base Reproduction:

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'

Instructions to re-train Removed Hidden Layer Ablation:

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'

Instructions to re-train Removed Max Entropy Ablation:

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'

Instructions to re-train Removed Discount Factor Ablation:

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'

Instructions to re-train Removed State Dimension Ablation:

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'

Instructions to re-train Leaky ReLU Ablation:

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'
Tip!

Press p or to see the previous file or, n or to see the next file

About

Maximum Entropy Deep inverse reinforcement learning suited for human social navigation within indoor spaces, like large malls.

Collaborators 1

Comments

Loading...