尝试使用 keras.layers.Input 构建模型时出错

问题描述 投票:0回答:0

我正在尝试在我的 ubuntu 系统上运行这段代码。我已经安装了 github 页面中提到的所有必需的包。运行 run_training.py 文件时出现以下错误:

回溯(最近调用最后):文件“run_training.py”,第 616 行,
在主要() main
中的文件“run_training.py”,第 611 行 开始训练(样本文件列表) 文件“run_training.py”,第 199 行,在 start_training model_1 = train_model(samples_list_train, samples_list_val, model_1_name) 文件“run_training.py”,第 126 行,在 train_model model = 创建_模型() 文件“run_training.py”,第 120 行,在 create_model network_model = RadNet(run_config.input_shape, drop_rate=run_config.drop_rate, l2_reg=run_config.l2_reg) 文件“/home/cdac/Downloads/msc_thesis/src/rad_net.py”,第 34 行,位于 init self._model = self._build_model() 文件“/home/cdac/Downloads/msc_thesis/src/rad_net.py”,第 85 行,在
_build_model 返回模型(输入=[rgb_input,radar_input,k_mat,decalib_gt_trans],输出=[predicted_decalib_quat,
depth_maps_predicted, cloud_pred]) 文件
“/home/cdac/.local/lib/python3.7/site-packages/keras/legacy/interfaces.py”, 第 87 行,在包装器中 return func(*args, **kwargs) 文件
“/home/cdac/.local/lib/python3.7/site-packages/keras/engine/topology.py”, 第 1591 行,在 init node = layer.inbound_nodes[node_index] IndexError:列表索引超出范围

根据我的检查,这是 run_training.py 中给出 error:

的部分

def _build_model(self):
        with tf.name_scope('rgb_stream'):
            rgb_input = Input(shape=self._rgb_shape)
            rgb_stream_out = self._rgb_stream(rgb_input)
        with tf.name_scope('radar_stream'):
            radar_input = Input(shape=self._radar_shape)
            radar_stream_out = MaxPooling2D(pool_size=(4,4))(radar_input)
        with tf.name_scope('calibration_block'):
            predicted_decalib_quat = self._calibration_block(rgb_stream_out, radar_stream_out)
            predicted_decalib_quat = Lambda(lambda x: tf.map_fn(lambda x: (tf.where(x[0] < 0.0, tf.negative(x), x)), x))(predicted_decalib_quat)
         
            predicted_decalib_quat = Lambda(lambda x: tf.map_fn(lambda x:x *tf.constant([1.0, 0.0, 1.0, 0.0]), x), name="quat")(predicted_decalib_quat)

        with tf.name_scope('se3_block'):
            k_mat = Input(shape=(3, 4))
            decalib_gt_trans = Input(shape=(3, ))
            stl_output = Lambda(self._spatial_transformer_layers, name="ST_Layer")([predicted_decalib_quat, radar_input, k_mat, decalib_gt_trans])
            depth_maps_predicted = Lambda(lambda x: x, name="depth_maps")(stl_output[0])
            cloud_pred = Lambda(lambda x: x, name="cloud")(stl_output[1])

        # Compose model.
        print('inputs ** ','rgb_input', rgb_input, 'radar_input', radar_input,'k_mat',k_mat, 'decalib_gt_trans', decalib_gt_trans)
        print('outputs ** ','predicted_decalib_quat', predicted_decalib_quat, 'depth_maps_predicted', depth_maps_predicted,'cloud_pred',cloud_pred)

        return Model(inputs=[rgb_input, radar_input, k_mat, decalib_gt_trans], outputs=[predicted_decalib_quat, depth_maps_predicted, cloud_pred])

打印输入输出时我得到的输出是:

inputs **  rgb_input Tensor("rgb_stream/input_1:0", shape=(?, 150, 240, 3), dtype=float32) radar_input Tensor("radar_stream/input_2:0", shape=(?, 150, 240, 1), dtype=float32) k_mat Tensor("se3_block/input_3:0", shape=(?, 3, 4), dtype=float32) decalib_gt_trans Tensor("se3_block/input_4:0", shape=(?, 3), dtype=float32)

outputs **  predicted_decalib_quat Tensor("calibration_block/quat/map/TensorArrayStack/TensorArrayGatherV3:0", shape=(?, 4), dtype=float32)  depth_maps_predicted Tensor("se3_block/depth_maps/Identity:0", shape=(?, 150, 240), dtype=float32)  cloud_pred Tensor("se3_block/cloud/Identity:0",shape=(?, 125, 3), dtype=float32)

任何人都可以帮我找到解决方案吗?

我正在使用 Ubuntu 16.04、tensorflow-gpu 1.13.1、keras 2.0.9、pyhton 3.7

python-3.x tensorflow computer-vision gpu ubuntu-16.04
© www.soinside.com 2019 - 2024. All rights reserved.