tensorflow / tensorflow/models
ValueError: Dimension 1 in both shapes must be equal, but are 13 and 14.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.7k
- Forks
- 44.8k
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I am new to this and coming across an issue that I do not quite understand. Appreciate any help here!
I have input images of size 800x1066 (sometimes 1067). I've generated my tfrecords and beginning to train (run model_main_tf2.py). I am using Tensorflow Object Detection API, and made some changes to the default EfficientNet-b0 configuration file.
The issue: I am getting a ValueError: Exception encountered when calling layer "1_dn_lvl_6/combine" (type BiFPNCombineLayer).
In particular: ValueError: Dimension 1 in both shapes must be equal, but are 13 and 14. Shapes are [4,13,17,64] an
d [4,14,18,64]. From merging shape 0 with other shapes. for '{{node EfficientDet-D0/bifpn/node_02/1_dn_lvl_
6/combine/stack}} = Pack[N=2, T=DT_FLOAT, axis=-1](EfficientDet-D0/bifpn/node_00/0_up_lvl_6/input_0_up_lvl_5/downsa
mple_max_x2/MaxPool, EfficientDet-D0/bifpn/node_02/1_dn_lvl_6/input_0_up_lvl_7/nearest_neighbor_upsampling_x2/neare
st_neighbor_upsampling/Reshape)' with input shapes: [4,13,17,64], [4,14,18,64].
I do not quite understand what this error means. It seems like it is related to my input images. Is it incorrect to be using input images that are rectangular (in my case 800x1067)?
This is what my pipeline.config looks like:
# SSD with EfficientNet-b0 + BiFPN feature extractor,
# shared box predictor and focal loss (a.k.a EfficientDet-d0).
# See EfficientDet, Tan et al, https://arxiv.org/abs/1911.09070
# See Lin et al, https://arxiv.org/abs/1708.02002
# Trained on COCO, initialized from an EfficientNet-b0 checkpoint.
#
# Train on TPU-8
model {
ssd {
inplace_batchnorm_update: true
freeze_batchnorm: false
num_classes: 1
add_background_class: false
box_coder {
faster_rcnn_box_coder {
y_scale: 10.0
x_scale: 10.0
height_scale: 5.0
width_scale: 5.0
}
}
matcher {
argmax_matcher {
matched_threshold: 0.5
unmatched_threshold: 0.5
ignore_thresholds: false
negatives_lower_than_unmatched: true
force_match_for_each_row: true
use_matmul_gather: true
}
}
similarity_calculator {
iou_similarity {
}
}
encode_background_as_zeros: true
anchor_generator {
multiscale_anchor_generator {
min_level: 3
max_level: 7
anchor_scale: 4.0
aspect_ratios: [1.0, 2.0, 0.5]
scales_per_octave: 3
}
}
image_resizer {
fixed_shape_resizer {
height: 800
width: 1067
resize_method: AREA
}
}
box_predictor {
weight_shared_convolutional_box_predictor {
depth: 64
class_prediction_bias_init: -4.6
conv_hyperparams {
force_use_bias: true
activation: SWISH
regularizer {
l2_regularizer {
weight: 0.00004
}
}
initializer {
random_normal_initializer {
stddev: 0.01
mean: 0.0
}
}
batch_norm {
scale: true
decay: 0.99
epsilon: 0.001
}
}
num_layers_before_predictor: 3
kernel_size: 3
use_depthwise: true
}
}
feature_extractor {
type: 'ssd_efficientnet-b0_bifpn_keras'
bifpn {
min_level: 3
max_level: 7
num_iterations: 3
num_filters: 64
}
conv_hyperparams {
force_use_bias: true
activation: SWISH
regularizer {
l2_regularizer {
weight: 0.00004
}
}
initializer {
truncated_normal_initializer {
stddev: 0.03
mean: 0.0
}
}
batch_norm {
scale: true,
decay: 0.99,
epsilon: 0.001,
}
}
}
loss {
classification_loss {
weighted_sigmoid_focal {
alpha: 0.25
gamma: 1.5
}
}
localization_loss {
weighted_smooth_l1 {
}
}
classification_weight: 1.0
localization_weight: 1.0
}
normalize_loss_by_num_matches: true
normalize_loc_loss_by_codesize: true
post_processing {
batch_non_max_suppression {
score_threshold: 1e-8
iou_threshold: 0.5
max_detections_per_class: 150
max_total_detections: 150
}
score_converter: SIGMOID
}
}
}
train_config: {
batch_size: 4
sync_replicas: true
startup_delay_steps: 0
replicas_to_aggregate: 8
use_bfloat16: true
num_steps: 30000
data_augmentation_options {
random_horizontal_flip {
}
}
data_augmentation_options {
random_vertical_flip {
}
}
data_augmentation_options {
random_adjust_brightness{
}
}
data_augmentation_options {
random_adjust_contrast{
}
}
data_augmentation_options {
random_adjust_hue{
}
}
data_augmentation_options {
random_adjust_saturation{
}
}
optimizer {
momentum_optimizer: {
learning_rate: {
cosine_decay_learning_rate {
learning_rate_base: 8e-2
total_steps: 30000
warmup_learning_rate: .001
warmup_steps: 250
}
}
momentum_optimizer_value: 0.9
}
use_moving_average: false
}
max_number_of_boxes: 150
unpad_groundtruth_tensors: false
}
train_input_reader: {
label_map_path: "<<my input path>>"
tf_record_input_reader {
input_path: "<<my input path>>"
}
}
eval_config: {
metrics_set: "coco_detection_metrics"
use_moving_averages: false
batch_size: 1;
}
eval_input_reader: {
label_map_path: "<<my input path>>"
shuffle: false
num_epochs: 1
tf_record_input_reader {
input_path: "<<my input path>>"
}
}
6. System information
- OS Platform and Distribution: macOS 12.0
- TensorFlow version (use command below): v2.7.0
- Python version: 3.7.12
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.