Skip to content

Commit

Permalink
Update reshaping logic in MulticoreBPFLayer to fix dimension mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
devin-ai-integration[bot] committed Jul 9, 2024
1 parent 9d621f0 commit c1920af
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripts/deep_learning_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ def call(self, inputs):
tf.print("Dimension mismatch: reshaped inputs shape", input_shape[1:], "does not match predicted_measurements shape", predicted_shape)
raise ValueError(f"Dimension mismatch: reshaped inputs shape {input_shape[1:]} does not match predicted_measurements shape {predicted_shape}")

reshaped_inputs = tf.reshape(inputs, [input_shape[0], predicted_shape[1], predicted_shape[0]])
reshaped_inputs = tf.reshape(inputs, [input_shape[0], predicted_shape[0], predicted_shape[1]])
tf.print("Shape of reshaped_inputs:", tf.shape(reshaped_inputs))

# Ensure reshaped_inputs and predicted_measurements are compatible for element-wise subtraction
if reshaped_inputs.shape != tf.transpose(predicted_measurements).shape:
raise ValueError(f"Shape mismatch: reshaped_inputs shape {reshaped_inputs.shape} does not match transposed predicted_measurements shape {tf.transpose(predicted_measurements).shape}")
if reshaped_inputs.shape != predicted_measurements.shape:
raise ValueError(f"Shape mismatch: reshaped_inputs shape {reshaped_inputs.shape} does not match predicted_measurements shape {predicted_measurements.shape}")

self.particle_weights.assign(tf.reduce_sum(tf.square(reshaped_inputs - tf.transpose(predicted_measurements)), axis=-1))
self.particle_weights.assign(tf.reduce_sum(tf.square(reshaped_inputs - predicted_measurements), axis=-1))

# Resample particles based on weights
resampled_indices = tf.random.categorical(tf.math.log(tf.expand_dims(self.particle_weights, 0)), self.num_particles)
Expand Down

0 comments on commit c1920af

Please sign in to comment.