CNTK Convolution1d

I am trying to create a simple convolution model in CNTK as shown below

def create_model(hidden_dim, output_dim):
    nn=C.layers.Sequential([ C.layers.Embedding(shape=50,name='embedding'),
        C.layers.Convolution1D((40,),num_filters=5, activation=C.ops.relu),
        C.layers.GlobalMaxPooling(),
        C.layers.Dense(shape=40, activation=C.ops.tanh, init_bias=0.1), 
        C.layers.Dense(shape=2, activation=None, init_bias=0.1)
        ])
    return nn

      

but I keep getting the following ValueError: The convolution map tensor must be of rank 1 or the same as the input tensor.

+3


source to share


1 answer


I managed to fix this issue by adding the reduce_rank = 0 parameter as a parameter to the Convolution1d level.

def create_model(hidden_dim, output_dim):
nn=C.layers.Sequential([ C.layers.Embedding(shape=50,name='embedding', **reduction_rank=0**),
    C.layers.Convolution1D((40,),num_filters=5, activation=C.ops.relu),
    C.layers.GlobalMaxPooling(),
    C.layers.Dense(shape=40, activation=C.ops.tanh, init_bias=0.1), 
    C.layers.Dense(shape=2, activation=None, init_bias=0.1)
    ])
return nn

      

Quote from CNTK Layers Documentation



reduce_rank (int, default 1) - Set to 0 if the input elements are scalars (the input has no depth axis), for example. beep or black and white image stored with tensor form (H, W) instead of (1, H, W)

I expected CNTK to be able to automatically output this thing

+1


source







All Articles