Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade the K : number of channel #1494

Closed
souzou opened this issue Nov 27, 2014 · 3 comments
Closed

upgrade the K : number of channel #1494

souzou opened this issue Nov 27, 2014 · 3 comments
Labels

Comments

@souzou
Copy link

souzou commented Nov 27, 2014

Hello,

In my research I wan't to upgrade the number of channel K, for exemple to use 4 or 5 channel adding to RGB,
My question is where can I found the file that define or allow me to define a bigger number of channels?
Thx :)

@bhack
Copy link
Contributor

bhack commented Nov 27, 2014

Try to take a look here #1486

@shelhamer
Copy link
Member

Caffe is general w.r.t. to the number of input channels K. In Caffe there's no need to explicitly define the input channel, height, or width dimensionality in the model as it is loaded from the data. Prepare the data in an LMDB or your format of choice with each feature channel included:

import numpy as np
import caffe
import lmdb

# obviously load your own inputs here -- this is just by way of example
# to show the data can have any channel dimension
# as the dimensions are N x K x H x W
inputs = np.zeros((10, 5, 227, 227))

in_db = lmdb.open('input-lmdb', map_size=int(1e12))
with in_db.begin(write=True) as in_txn:
    for in_idx, in_ in enumerate(inputs):
        in_dat = caffe.io.array_to_datum(in_)
        in_txn.put('{:0>10d}'.format(in_idx), im_dat.SerializeToString())
in_db.close()

There's no need for N-D blobs to simply increase the channel dimension K. If you had volumetric data on the other hand (a whole new axis of the data, not more dimensions of a given axis) then N-D blobs would be needed.

@ToruHironaka
Copy link

I have a question for making sure of upgrading K channel number. I could create my dataset with K channel 4 by your script or convert_imageset and I changed K channel number on deploy.prototxt but I got a trouble when I classified an image with caffe.Classifier. It caused an error: "blob.cpp:455] Check failed: ShapeEquals(proto) shape mismatch (reshape not set)". This error was understandable because I increased the number of K channel from 3 to 4 in deploy.prototxt while I was training. However, I changed K channel back to 4 from 3 in deploy.prototxt and classify an image again. The error problem was solved and I could classify with my trained model. Is this because caffe does not have to explicitly defined K channel you mentioned here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants