【问题标题】:tbb layer dimension mismatch CNN/Pytorch codetbb 层维度不匹配 CNN/Pytorch 代码
【发布时间】:2021-09-10 00:45:24
【问题描述】:

我有一个 CNN 测试代码,它从 pytorch 训练数据中读取 CNN 参数并在 CNN 上对其进行测试,代码运行良好,但我尝试使用 tbb parallel_for 来提高性能,因此我将循环从

for (j = 0; j < layerstrings.size(); j++) {
    LAYER_INF *p = layerstrings.at(j);
    arg1 = p->arg1;
    arg2 = p->arg2;
    arg3 = p->arg3;
    arg4 = p->arg4;
    arg5 = p->arg5;

parallel_for(size_t(0), layerstrings.size(), [&](size_t j) {
    LAYER_INF *p = layerstrings.at(j);
    arg1 = p->arg1;
    arg2 = p->arg2;
    arg3 = p->arg3;
    arg4 = p->arg4;
    arg5 = p->arg5;

但我不断收到此错误

terminate called after throwing an instance of 'tbb::captured_exception'

what(): 层尺寸不匹配! 第 N 层的输出大小必须等于第 (N+1) 层的输入 第N层:输入:784([[28x28x1],[5x5x6],[1x1x6]]),输出:3456([[24x24x6]]) layerN+1: 全连接 in:160([[160x1x1],[160x10x1],[10x1x1]]), out:10([[10x1x1]]) 3456 != 160

PyTorch cnn 结构看起来像

model = nn.Sequential(
      nn.Conv2d(1,6,5),
      nn.AvgPool2d(2,2),
      nn.ReLU(),
      nn.Conv2d(6,10,5),
      nn.AvgPool2d(2,2),
      nn.ReLU(),
      nn.Flatten(),
      nn.Linear(160,10),
      nn.Sigmoid()
    )

有什么想法或建议吗??

【问题讨论】:

    标签: c++ debugging pytorch conv-neural-network tbb


    【解决方案1】:

    我认为这个问题主要是因为缺乏运行 CNN 的空间。你能检查一下你是否有足够的 RAM 来运行具有指定维度的 CNN 模型吗?您也可以参考以下链接进行进一步说明

    https://software.intel.com/content/www/us/en/develop/documentation/tbb-documentation/top/intel-threading-building-blocks-developer-reference/appendices/deprecated-features/obsolete-c-functionality/exceptions/capturedexception.html

    【讨论】:

      猜你喜欢
      • 2017-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-20
      • 2020-07-07
      • 1970-01-01
      相关资源
      最近更新 更多