FailedPreconditionError: Ресурс localhost / _AnonymousVar404 / N10tensorflow3VarE не существует - PullRequest
0 голосов
/ 16 апреля 2020

Я новичок в глубоком обучении и python, я пытался запустить keras R-FCN Я google colab, и у меня появилась такая ошибка

tensorflow.python.framework.errors_impl.FailedPreconditionError: 2 root error(s) found.
  (0) Failed precondition:  Error while reading resource variable _AnonymousVar404 from Container: localhost. This could mean that the variable was uninitialized. Not found: Resource localhost/_AnonymousVar404/N10tensorflow3VarE does not exist.
     [[node regr_vote/crop_to_bounding_box_7/stack/ReadVariableOp_1 (defined at usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:3009) ]]
  (1) Cancelled:  Function was cancelled before it was started
0 successful operations.
0 derived errors ignored. [Op:__inference_keras_scratch_graph_16906]

Я думаю, что функция crop_to_bounding_box имеет что-то это неинициализированный, и это код, который называется crop_to_bounding_box

# position-sensitive ROI pooling + classify
        score_map_bins = []
        for channel_step in range(self.k*self.k):
            bin_x = K.variable(int(channel_step % self.k) *
                               self.pool_shape, dtype='int32')
            print(bin_x)
            bin_y = K.variable(int(channel_step / self.k) *
                               self.pool_shape, dtype='int32')
            channel_indices = K.variable(list(range(
                channel_step*self.channel_num, (channel_step+1)*self.channel_num)), dtype='int32')
            croped = tf.image.crop_to_bounding_box(
                tf.gather(pooled, indices=channel_indices, axis=-1), bin_y, bin_x, self.pool_shape, self.pool_shape)
            # [pool_shape, pool_shape, channel_num] ==> [1,1,channel_num] ==> [1, channel_num]
            croped_mean = K.pool2d(croped, (self.pool_shape, self.pool_shape), strides=(
                1, 1), padding='valid', data_format="channels_last", pool_mode='avg')
            # [batch * num_rois, 1,1,channel_num] ==> [batch * num_rois, 1, channel_num]
            croped_mean = K.squeeze(croped_mean, axis=1)
            score_map_bins.append(croped_mean)

Я использую GPU tenorflow-v2.1.0 и Keras 2.3.1

ОБНОВЛЕНО: вероятно, потому что я добавляю K.variable внутри l oop, если я попытался прокомментировать K.variable, код работает отлично, но мне нужно изменить K.variable на основе channel_step.

как обновить K.variable, чтобы я мог определить K.variable снаружи l oop, и обновить значение внутри l oop на основе channel_step?

1 Ответ

0 голосов
/ 26 апреля 2020

Я нашел решение этой проблемы, мне просто нужно понизить версию Keras и TensorFlow. Сейчас я использую tenorflow-GPU 1.15.0 и Keras 2.2.4. По-видимому, этот код не поддерживает TensorFlow 2 и более поздние версии.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...