I’m trying to implement a variant of an algorithm (ArXiv: 1708.05344) that changes a part of its network for each backprop, and the following piece causes an error.
class SMASH(nn.Module):
    #................
    def forward(self, x, arch, W):
        num_output_units = arch['num_output_units']
        depth = arch['depth']
        #....(unpacking arch continues)....
        #....(then, network is built here according to variables in arch)....
        return F.log_softmax(x) #where x has passed through the network

This results in the following error message, i.e., using string as an index as in dictionary is forbidden in this case. However, since arch contains up to 20 variables, and since the set of variables in arch is different for different types of NN to consider, use of dictionary would be very helpful. Is there no way to avoid this error using dictionary?
File "/home/ubuntu/SMASH-master/SMASH.py", line 312, in forward
network_type = arch['network_type']
File "/usr/local/lib/python3.5/dist-packages/torch/autograd/variable.py", line 76, in __getitem__
return Index.apply(self, key)
File "/usr/local/lib/python3.5/dist-packages/torch/autograd/_functions/tensor.py", line 16, in forward
result = i.index(ctx.index)
TypeError: indexing a tensor with an object of type str. The only supported types are integers, slices, numpy scalars and torch.cuda.LongTensor or torch.cuda.ByteTensor as the only argument.