How could I get the input name and shape of a pretrained model

Hi,

I am using the model pretrained before, and I do not know the shape and name of the inputs. All I got is a params file and a json file. I am trying to define a shape dict like this: {'data': (1, 3, 224, 224)} where the (1, 3, 224, 224) is the shape of the dummy input when the model is exported.

How could I know the name of the shape of a given model please?

There are a couple of ways one you can try:

 shape = (1, 3, 32, 32)  
mx.viz.print_summary(
    net(mx.sym.var('data')),
    shape={'data': shape})

This will print a summary of the layers gives names along with parameters.

This one is probably better given your description:

use this function:

def get_layer_output(symbol, arg_params, aux_params, layer_name):
    all_layers = symbol.get_internals()
    net = all_layers[layer_name+'0']
    net = mx.symbol.Flatten(data=net)
    new_args = dict({k:arg_params[k] for k in arg_params if k in net.list_arguments()})
    new_aux = dict({k:aux_params[k] for k in aux_params if k in net.list_arguments()})
    return (net, new_args, new_aux)

then use sym.get_internals() and this will print all the layers and names.

Hope one of these works.

Sorry that was the wrong link and the one I found is already in here, but just in case you haven’t seen it. This also show how to print out layer names.