Я строю модель для обучения сверточной нейронной сети, проблема в том, что при создании модели она говорит, что у меня есть ошибка, я подозреваю, что, возможно, это связано с несовместимостью версий тензорного потока.
Код ниже (ошибка 4-й строки):
# define the RPN, built on the base layers
num_anchors = len(C.anchor_box_scales) * len(C.anchor_box_ratios) # 9
rpn = rpn_layer(shared_layers, num_anchors)
classifier = classifier_layer(shared_layers, roi_input, C.num_rois, nb_classes=len(classes_count))
model_rpn = Model(img_input, rpn[:2])
model_classifier = Model([img_input, roi_input], classifier)
# this is a model that holds both the RPN and the classifier, used to load/save weights for the models
model_all = Model([img_input, roi_input], rpn[:2] + classifier)
# Because the google colab can only run the session several hours one time (then you need to connect again),
# we need to save the model and load the model to continue training
if not os.path.isfile(C.model_path):
#If this is the begin of the training, load the pre-traind base network such as vgg-16
try:
print('This is the first time of your training')
print('loading weights from {}'.format(C.base_net_weights))
model_rpn.load_weights(C.base_net_weights, by_name=True)
model_classifier.load_weights(C.base_net_weights, by_name=True)
except:
print('Could not load pretrained model weights. Weights can be found in the keras application folder \
https://github.com/fchollet/keras/tree/master/keras/applications')
# Create the record.csv file to record losses, acc and mAP
record_df = pd.DataFrame(columns=['mean_overlapping_bboxes', 'class_acc', 'loss_rpn_cls', 'loss_rpn_regr', 'loss_class_cls', 'loss_class_regr', 'curr_loss', 'elapsed_time', 'mAP'])
else:
# If this is a continued training, load the trained model from before
print('Continue training based on previous trained model')
print('Loading weights from {}'.format(C.model_path))
model_rpn.load_weights(C.model_path, by_name=True)
model_classifier.load_weights(C.model_path, by_name=True)
# Load the records
record_df = pd.read_csv(record_path)
r_mean_overlapping_bboxes = record_df['mean_overlapping_bboxes']
r_class_acc = record_df['class_acc']
r_loss_rpn_cls = record_df['loss_rpn_cls']
r_loss_rpn_regr = record_df['loss_rpn_regr']
r_loss_class_cls = record_df['loss_class_cls']
r_loss_class_regr = record_df['loss_class_regr']
r_curr_loss = record_df['curr_loss']
r_elapsed_time = record_df['elapsed_time']
r_mAP = record_df['mAP']
print('Already train %dK batches'% (len(record_df)))
И вот что получилось:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-55-039b2b159de7> in <module>()
2 rpn = rpn_layer(shared_layers, num_anchors)
3
----> 4 classifier = classifier_layer(shared_layers, roi_input, C.num_rois, nb_classes=len(classes_count))
5
6 model_rpn = Model(img_input, rpn[:2])
1 frames
<ipython-input-33-3ad8e8cb6f84> in __init__(self, pool_size, num_rois, **kwargs)
19 def __init__(self, pool_size, num_rois, **kwargs):
20
---> 21 self.dim_ordering = K.image_dim_ordering()
22 self.pool_size = pool_size
23 self.num_rois = num_rois
AttributeError: module 'keras.backend' has no attribute 'image_dim_ordering'
Я не знаю, как это исправить, любая помощь приветствуется.