Mxnet deepdog (hot dog not hot dog) example - how does the network know it is classifying a hotdog Looking at the mxnet documentation.
It takes the pretrained squeenext1_1 weights, and sets imagenet_hotdog_index variable to 713.
    net = models.squeezenet1_1(pretrained=True, prefix='deep_dog_', ctx=contexts)
# hot dog happens to be a class in imagenet.
# we can reuse the weight for that class for better performance
# here's the index for that class for later use
imagenet_hotdog_index = 713

Then they set a 2 class output layer on top of it
    deep_dog_net = models.squeezenet1_1(prefix='deep_dog_', classes=2)
deep_dog_net.collect_params().initialize(ctx=contexts)
deep_dog_net.features = net.features
print(deep_dog_net)

Where I get confused is in the classify_hotog function - it is applying softmax to the output layer, and then returning the highest result index. This would make perfect sense if we had somehow told the network to compare against index 713. But it is called for prediction before the index variable is being reused? How does the network know the class to compare against is index 713/hot dog? We've basically taken squeezenet and reduced it down to 2 class output. But how does the network know what class to compare it to? Why would it give a high probability to the second argument/class when showing a hotdog - seems to me it shouldn't know what class it is comparing it to?
out = mx.nd.SoftmaxActivation(net(image.as_in_context(contexts[0])))
print('Probabilities are: '+str(out[0].asnumpy()))
result = np.argmax(out.asnumpy())

I would have expected it to maybe use the full squeezenet output layer, and set something like
if np.argmax(out.asnumpy()) == 713:
     &quot;Hot Dog!'
Else:
     &quot;Not hot dog!&quot;

Never understood this and would appreciate if anyone could help me get this detail.
You are on the right track. But you would have to realize that 713 is only, effectively, being used as an index lookup to get the weights just for that class and "seed" your new model. From there, model becomes a binary classification model where 0 is nothotdog and 1 is hotdog. Once the weights are picked up, 713 shouldn't be found anywhere else in your model. 

So the output, initially, is going to be something [0.493, 0.507], each corresponding to the probability that the image belongs to one of the two classes. From there, the call with argmax() is looking for which probability is highest, according to the binary selection. So it would pick 0.507 and call it a hotdog since that's corresponds to the binary value of 1. 

If you want to verify me on all this, go to your output code and do something like print(out.asnumpy()) and you'll see what I mean.