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

Slice or split data using python NetSpec() #4497

Closed
inferrna opened this issue Jul 21, 2016 · 3 comments
Closed

Slice or split data using python NetSpec() #4497

inferrna opened this issue Jul 21, 2016 · 3 comments

Comments

@inferrna
Copy link

I need to split input some data into 3 blocks, process all it separately and join after. When I try to get knowing count of tops it gives me this error:

    n.lr, n.lg, n.lb = L.Slice(n.data, slice_param={'axis':1})
TypeError: 'Top' object is not iterable

When I changed code to

    n.lr = L.Slice(n.data, slice_param={'axis':1})

it seems to works and even produces block inside prototxt:

layer {
  name: "lr"
  type: "Slice"
  bottom: "data"
  top: "lr"
  slice_param {
    axis: 1
  }
}

but really it just leaves data unchanged:

I0722 01:55:31.749025 14994 net.cpp:160] Setting up data
I0722 01:55:31.749075 14994 net.cpp:168] Top shape: 32 3 8 1280 (983040)
I0722 01:55:31.749099 14994 layer_factory.hpp:78] Creating layer lr
I0722 01:55:31.749116 14994 net.cpp:109] Creating Layer lr
I0722 01:55:31.749145 14994 net.cpp:470] lr <- data
I0722 01:55:31.749157 14994 net.cpp:439] lr -> lr
I0722 01:55:31.749181 14994 net.cpp:160] Setting up lr
I0722 01:55:31.749191 14994 net.cpp:168] Top shape: 32 3 8 1280 (983040)

If I wrong somewhere, it would be nice to see example how to do it properly.

@myyan92
Copy link

myyan92 commented Jul 28, 2016

I am having the same problem. I also tried
n.top = L.Slice(n.bottom, slice_param=dict(axis=0,slice_point=[batchsize,2*batchsize]), top=[n.top1,n.top2])
then there is keyError on n.top1

@lliuz
Copy link

lliuz commented Aug 16, 2016

you should use

n.lr = L.Slice(n.data, slice_param={'axis':1}, ntop=3)

@hongzhenwang
Copy link

The write code is
n.lr, n.lg, n.lb = L.Slice(n.data, slice_param={'axis':1},ntop=3)

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

4 participants