0

I'm trying to learn caffe by making an xor example.

I'm following this link from the caffe website, but they are doing a CNN.

I'm trying to follow along the tutorial and I am stuck when it comes to compiling the model.

I made a prototxt file describes the model architecture, I am trying to make a two layered xor network. My code is below:

name: "xor_test"

layer {
  name: "data"
  type: "Data"
  transform_param {
    scale: 1
  }
  data_param {
    source: "0 0 0
             1 0 1
             0 1 1
             1 1 0"

    backend: LMDB
    batch_size: 1
  }
  top: "data"
  top: "data"
}

layer {
  name: "ip1"
  type: "InnerProduct"
  param { lr_mult: 1 }
  param { lr_mult: 2 }
  inner_product_param {
    num_output: 3
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
  bottom: "data"
  top: "ip1"
}

layer {
  name: "tanh1"
  type: "Tanh"
  bottom: "ip1"
  top: "ip1"
}

layer {
  name: "ip2"
  type: "InnerProduct"
  param { lr_mult: 1 }
  param { lr_mult: 2 }
  inner_product_param {
    num_output: 1
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
  bottom: "ip1"
  top: "ip2"
}

layer {
  name: "tanh2"
  type: "Tanh"
  bottom: "ip2"
  top: "ip2"
}

I don't know if this model is correct, I can't find other examples to reference.

After this, the tutorial says to create a solver prototxt file which referenced the previously created file.

net: "test.prototxt"
test_iter: 2
test_interval: 5
base_lr: 0.01
momentum: 0.9
weight_decay: 0.0005
lr_policy: "inv"
gamma: 0.0001
power: 0.75
display: 5
# The maximum number of iterations
max_iter: 10
# solver mode: CPU or GPU
solver_mode: CPU

I'm not sure how to train or test the model since my inputs are not images.

Shai
  • 111,146
  • 38
  • 238
  • 371
user94758
  • 97
  • 1
  • 1
  • 8

1 Answers1

0

Your input layer is incorrect. Since you are not using images as inputs, but rather simple binary vectors, you might consider using HDF5Data layer for input.
There is a good example here on how to construct and use this input data layer.

Shai
  • 111,146
  • 38
  • 238
  • 371