26845
kerasを使って学習済みモデルの評価をしようとしています。しかし、重みを設定するとタイトルのようなエラーが出てしまいました。フィルタ数、つまり最初のnOutoutPlaneは32なのでweightsの数も32になると考えましたがなぜ2になるのでしょうか。

**エラー**

```

    You called `set_weights(weights)` on layer "convolution2d_1" with a  weight list of length 32, but the layer was expecting 2 weights.
    
```

**コード**

```

    def LoadModel(path, input_shape):
        params = None
        with open(path, 'rb') as f:
            params = json.load(f)
        model = Sequential()
        model.add(Convolution2D(
            params[0]['nOutputPlane'],
            params[0]['kH'],
            params[0]['kW'],
            border_mode='same',
            weights=params[0]['weight'],
            bias=params[0]['bias'],
            input_shape=input_shape))
        model.add(LeakyReLU(0.1))
        for param in params[1:]:
            model.add(Convolution2D(param['nOutputPlane'], param['kH'], param['kW'], border_mode='same', weights=param['weight'], bias=param['bias']))
            model.add(LeakyReLU(0.1))
    
        return model
    
```

input_shape = (1, [高さ], [幅])  
カーネルサイズ3x3です。  
最初のweightのサイズ = (32, 3, 3)  
最初のaddでエラーが出ます。
CC BY-SA 3.0
2016-06-18T11:17:59.320
26830
2016-06-19T01:17:30.127
2016-06-18T12:01:28.743
76
7232
question
python 深層学習 keras
You called `set_weights(weights)` on layer "convolution2d_1" with a weight list of length 32, but the layer was expecting 2 weights
```

    def LoadModel(path, input_shape):
        params = None
        with open(path, 'rb') as f:
            params = json.load(f)
        model = Sequential()
        model.add(Convolution2D(
            params[0]['nOutputPlane'],
            params[0]['kH'],
            params[0]['kW'],
            init='zero',
            border_mode='same',
            weights=[np.array(params[0]['weight']), np.array(params[0]['bias'])],
            bias=True,
            input_shape=input_shape))
        model.add(LeakyReLU(0.1))
        for param in params[1:]:
            model.add(Convolution2D(
                param['nOutputPlane'],
                param['kH'],
                param['kW'],
                init='zero',
                border_mode='same',
                weights=[np.array(param['weight']), np.array(param['bias'])],
                bias=True))
            model.add(LeakyReLU(0.1))
    
        return model
    
```
CC BY-SA 3.0
2016-06-19T01:17:30.127
26845
2016-06-19T01:17:30.127
7232
26830
answer