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

Support for Image Input? #6

Open
cwozny opened this issue Aug 23, 2019 · 1 comment
Open

Support for Image Input? #6

cwozny opened this issue Aug 23, 2019 · 1 comment

Comments

@cwozny
Copy link

cwozny commented Aug 23, 2019

I'm trying to adapt the example in the readme markdown to accept a grayscale input image with a resolution of 512x448 in the range 0-1 and an output of 8 values between 0-1. My dimensions seem to be incompatible somewhere along the line, but I can't figure out exactly where.

const int WIDTH = 512;
const int HEIGHT = 448;
const int DEPTH = 100;
const int KEYPAD = 8;

Eigen::MatrixXd screen(WIDTH*HEIGHT,DEPTH);
Eigen::MatrixXd keypad(KEYPAD,DEPTH);
Eigen::MatrixXd pred;

// Construct a network object
MiniDNN::Network net;

// Create three layers
// Layer 1 -- convolutional, input size 512x448x1, 1 output channels, filter size 5x5
MiniDNN::Layer* layer1 = new MiniDNN::Convolutional<MiniDNN::ReLU>(WIDTH, HEIGHT, 1, 1, 5, 5);
// Layer 2 -- max pooling, input size 16x16x1, pooling window size 3x3
MiniDNN::Layer* layer2 = new MiniDNN::MaxPooling<MiniDNN::ReLU>(16, 16, 1, 3, 3);
// Layer 3 -- fully connected, input size 5x5x1, output size 8
MiniDNN::Layer* layer3 = new MiniDNN::FullyConnected<MiniDNN::Identity>(5 * 5 * 1, KEYPAD);

// Add layers to the network object
net.add_layer(layer1);
net.add_layer(layer2);
net.add_layer(layer3);

// Set output layer
net.set_output(new MiniDNN::RegressionMSE());

// Create optimizer object
MiniDNN::RMSProp opt;
opt.m_lrate = 0.001;

// (Optional) set callback function object
MiniDNN::VerboseCallback callback;
net.set_callback(callback);

net.init(0, 0.01, 123);

// Populate observations and responses here...
...
...

net.fit(opt, screen, keypad, 100, 10, 123);

The above code when executed yields to the following error:

terminate called after throwing an instance of 'std::invalid_argument'
what(): Unit sizes do not match
Aborted (core dumped)

Any insight on what I am doing incorrectly @giovastabile or @yixuan?

@TrevorBlythe
Copy link

Is layer ones output size the same as layer twos input size???

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

No branches or pull requests

2 participants