Caffe Stacking LSTMs











up vote
1
down vote

favorite












I have an input feature sequence of size [3, 1, 1024], clip1 variable [0, 1, 1] and clip2 variable [1, 1, 0]. What I aim to do is to stack two LSTM layers to go through this feature sequence first from left to right and then right to left. My existing prototxt is as follows:



input: "data"
input_shape { dim: 3 dim: 1 dim: 1024}
input: "clip1"
input_shape { dim: 3 dim: 1}
input: "clip2"
input_shape { dim: 3 dim: 1}

layer {
name: "lstm1"
type: "LSTM"
bottom: "data"
bottom: "clip"
top: "lstm1"
recurrent_param {
num_output: 256
weight_filler {
type: "gaussian"
std: 0.1
}
bias_filler {
type: "constant"
value: 0
}
}

param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
param {
lr_mult: 1
decay_mult: 1
}
}

layer {
name: "lstm2"
type: "LSTM"
bottom: "lstm1"
bottom: "clip2"
top: "lstm2"
recurrent_param {
num_output: 512
weight_filler {
type: "gaussian"
std: 0.1
}
bias_filler {
type: "constant"
value: 0
}
}

param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
param {
lr_mult: 1
decay_mult: 1
}
}

layer {
name: "fc8-final"
type: "InnerProduct"
bottom: "lstm2"
top: "fc8-final"
param {
lr_mult: 10
decay_mult: 1
}
param {
lr_mult: 20
decay_mult: 0
}
inner_product_param {
num_output: 101
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
axis: 2
}
}
layer {
name: "probs"
type: "Softmax"
bottom: "fc8-final"
top: "probs"
softmax_param {
axis: 2
}
}
layer {
bottom: "probs"
bottom: "probs"
top: "loss"
name: "dummyLoss"
type: "EuclideanLoss"
}


Question:



Is my prototxt the correct way to implement my idea? or should I slice lstm1 blob and concatenate the sliced blobs in a reverse order and then input the concatenated blob to lstm2 layer?










share|improve this question


























    up vote
    1
    down vote

    favorite












    I have an input feature sequence of size [3, 1, 1024], clip1 variable [0, 1, 1] and clip2 variable [1, 1, 0]. What I aim to do is to stack two LSTM layers to go through this feature sequence first from left to right and then right to left. My existing prototxt is as follows:



    input: "data"
    input_shape { dim: 3 dim: 1 dim: 1024}
    input: "clip1"
    input_shape { dim: 3 dim: 1}
    input: "clip2"
    input_shape { dim: 3 dim: 1}

    layer {
    name: "lstm1"
    type: "LSTM"
    bottom: "data"
    bottom: "clip"
    top: "lstm1"
    recurrent_param {
    num_output: 256
    weight_filler {
    type: "gaussian"
    std: 0.1
    }
    bias_filler {
    type: "constant"
    value: 0
    }
    }

    param {
    lr_mult: 1
    decay_mult: 1
    }
    param {
    lr_mult: 2
    decay_mult: 0
    }
    param {
    lr_mult: 1
    decay_mult: 1
    }
    }

    layer {
    name: "lstm2"
    type: "LSTM"
    bottom: "lstm1"
    bottom: "clip2"
    top: "lstm2"
    recurrent_param {
    num_output: 512
    weight_filler {
    type: "gaussian"
    std: 0.1
    }
    bias_filler {
    type: "constant"
    value: 0
    }
    }

    param {
    lr_mult: 1
    decay_mult: 1
    }
    param {
    lr_mult: 2
    decay_mult: 0
    }
    param {
    lr_mult: 1
    decay_mult: 1
    }
    }

    layer {
    name: "fc8-final"
    type: "InnerProduct"
    bottom: "lstm2"
    top: "fc8-final"
    param {
    lr_mult: 10
    decay_mult: 1
    }
    param {
    lr_mult: 20
    decay_mult: 0
    }
    inner_product_param {
    num_output: 101
    weight_filler {
    type: "gaussian"
    std: 0.01
    }
    bias_filler {
    type: "constant"
    value: 0
    }
    axis: 2
    }
    }
    layer {
    name: "probs"
    type: "Softmax"
    bottom: "fc8-final"
    top: "probs"
    softmax_param {
    axis: 2
    }
    }
    layer {
    bottom: "probs"
    bottom: "probs"
    top: "loss"
    name: "dummyLoss"
    type: "EuclideanLoss"
    }


    Question:



    Is my prototxt the correct way to implement my idea? or should I slice lstm1 blob and concatenate the sliced blobs in a reverse order and then input the concatenated blob to lstm2 layer?










    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have an input feature sequence of size [3, 1, 1024], clip1 variable [0, 1, 1] and clip2 variable [1, 1, 0]. What I aim to do is to stack two LSTM layers to go through this feature sequence first from left to right and then right to left. My existing prototxt is as follows:



      input: "data"
      input_shape { dim: 3 dim: 1 dim: 1024}
      input: "clip1"
      input_shape { dim: 3 dim: 1}
      input: "clip2"
      input_shape { dim: 3 dim: 1}

      layer {
      name: "lstm1"
      type: "LSTM"
      bottom: "data"
      bottom: "clip"
      top: "lstm1"
      recurrent_param {
      num_output: 256
      weight_filler {
      type: "gaussian"
      std: 0.1
      }
      bias_filler {
      type: "constant"
      value: 0
      }
      }

      param {
      lr_mult: 1
      decay_mult: 1
      }
      param {
      lr_mult: 2
      decay_mult: 0
      }
      param {
      lr_mult: 1
      decay_mult: 1
      }
      }

      layer {
      name: "lstm2"
      type: "LSTM"
      bottom: "lstm1"
      bottom: "clip2"
      top: "lstm2"
      recurrent_param {
      num_output: 512
      weight_filler {
      type: "gaussian"
      std: 0.1
      }
      bias_filler {
      type: "constant"
      value: 0
      }
      }

      param {
      lr_mult: 1
      decay_mult: 1
      }
      param {
      lr_mult: 2
      decay_mult: 0
      }
      param {
      lr_mult: 1
      decay_mult: 1
      }
      }

      layer {
      name: "fc8-final"
      type: "InnerProduct"
      bottom: "lstm2"
      top: "fc8-final"
      param {
      lr_mult: 10
      decay_mult: 1
      }
      param {
      lr_mult: 20
      decay_mult: 0
      }
      inner_product_param {
      num_output: 101
      weight_filler {
      type: "gaussian"
      std: 0.01
      }
      bias_filler {
      type: "constant"
      value: 0
      }
      axis: 2
      }
      }
      layer {
      name: "probs"
      type: "Softmax"
      bottom: "fc8-final"
      top: "probs"
      softmax_param {
      axis: 2
      }
      }
      layer {
      bottom: "probs"
      bottom: "probs"
      top: "loss"
      name: "dummyLoss"
      type: "EuclideanLoss"
      }


      Question:



      Is my prototxt the correct way to implement my idea? or should I slice lstm1 blob and concatenate the sliced blobs in a reverse order and then input the concatenated blob to lstm2 layer?










      share|improve this question













      I have an input feature sequence of size [3, 1, 1024], clip1 variable [0, 1, 1] and clip2 variable [1, 1, 0]. What I aim to do is to stack two LSTM layers to go through this feature sequence first from left to right and then right to left. My existing prototxt is as follows:



      input: "data"
      input_shape { dim: 3 dim: 1 dim: 1024}
      input: "clip1"
      input_shape { dim: 3 dim: 1}
      input: "clip2"
      input_shape { dim: 3 dim: 1}

      layer {
      name: "lstm1"
      type: "LSTM"
      bottom: "data"
      bottom: "clip"
      top: "lstm1"
      recurrent_param {
      num_output: 256
      weight_filler {
      type: "gaussian"
      std: 0.1
      }
      bias_filler {
      type: "constant"
      value: 0
      }
      }

      param {
      lr_mult: 1
      decay_mult: 1
      }
      param {
      lr_mult: 2
      decay_mult: 0
      }
      param {
      lr_mult: 1
      decay_mult: 1
      }
      }

      layer {
      name: "lstm2"
      type: "LSTM"
      bottom: "lstm1"
      bottom: "clip2"
      top: "lstm2"
      recurrent_param {
      num_output: 512
      weight_filler {
      type: "gaussian"
      std: 0.1
      }
      bias_filler {
      type: "constant"
      value: 0
      }
      }

      param {
      lr_mult: 1
      decay_mult: 1
      }
      param {
      lr_mult: 2
      decay_mult: 0
      }
      param {
      lr_mult: 1
      decay_mult: 1
      }
      }

      layer {
      name: "fc8-final"
      type: "InnerProduct"
      bottom: "lstm2"
      top: "fc8-final"
      param {
      lr_mult: 10
      decay_mult: 1
      }
      param {
      lr_mult: 20
      decay_mult: 0
      }
      inner_product_param {
      num_output: 101
      weight_filler {
      type: "gaussian"
      std: 0.01
      }
      bias_filler {
      type: "constant"
      value: 0
      }
      axis: 2
      }
      }
      layer {
      name: "probs"
      type: "Softmax"
      bottom: "fc8-final"
      top: "probs"
      softmax_param {
      axis: 2
      }
      }
      layer {
      bottom: "probs"
      bottom: "probs"
      top: "loss"
      name: "dummyLoss"
      type: "EuclideanLoss"
      }


      Question:



      Is my prototxt the correct way to implement my idea? or should I slice lstm1 blob and concatenate the sliced blobs in a reverse order and then input the concatenated blob to lstm2 layer?







      caffe lstm






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 7 at 7:32









      Johnnylin

      161113




      161113





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53185141%2fcaffe-stacking-lstms%23new-answer', 'question_page');
          }
          );

          Post as a guest





































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53185141%2fcaffe-stacking-lstms%23new-answer', 'question_page');
          }
          );

          Post as a guest




















































































          這個網誌中的熱門文章

          Tangent Lines Diagram Along Smooth Curve

          Yusuf al-Mu'taman ibn Hud

          Zucchini