python - Keras error with merge layer -
i trying build model colorize images. using lab color space. input model l channel , model trained predict , b channels. want run l channel through few convolutions , split off 2 other models independently calculate , b channels. @ end want merge them output.
model = sequential() model.add(inputlayer((1, h, w))) model.add(convolution2d(64, 5, 5, border_mode = 'same', activation = 'relu')) model.add(convolution2d(64, 5, 5, border_mode = 'same', activation = 'relu')) last = convolution2d(64, 5, 5, border_mode = 'same', activation = 'relu') model.add(last) a_model = sequential() a_model.add(last) a_model.add(convolution2d(64, 5, 5, border_mode = 'same', activation = 'relu')) a_model.add(convolution2d(64, 5, 5, border_mode = 'same', activation = 'relu')) a_model.add(convolution2d(1, 3, 3, border_mode = 'same', activation = 'sigmoid')) b_model = sequential() b_model.add(last) b_model.add(convolution2d(64, 5, 5, border_mode = 'same', activation = 'relu')) b_model.add(convolution2d(64, 5, 5, border_mode = 'same', activation = 'relu')) b_model.add(convolution2d(1, 3, 3, border_mode = 'same', activation = 'sigmoid')) model.add(merge((a_model, b_model), mode = 'concat'))
i following error when try create merge layer.
using theano backend. using gpu device 0: geforce gtx titan (cnmem disabled, cudnn 5004) traceback (most recent call last): file "/home/chase/workspace/colorizer/colorizer2.py", line 79, in <module> model.add(merge((a_model, b_model), mode = 'concat')) file "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 1118, in __init__ self.add_inbound_node(layers, node_indices, tensor_indices) file "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 524, in add_inbound_node assert len(node_indices) == len(inbound_layers) assertionerror
i want outut of model (2, h, w) h , w image height , width.
the sequential
model doesn't allow create forks in network. use functional api (new in keras 1.0) instead. can follow this tutorial.
Comments
Post a Comment