Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. net = models.squeezenet1_1(pretrained=True, prefix='deep_dog_', ctx=contexts)
  2. # hot dog happens to be a class in imagenet.
  3. # we can reuse the weight for that class for better performance
  4. # here's the index for that class for later use
  5. imagenet_hotdog_index = 713
  6.  
  7. deep_dog_net = models.squeezenet1_1(prefix='deep_dog_', classes=2)
  8. deep_dog_net.collect_params().initialize(ctx=contexts)
  9. deep_dog_net.features = net.features
  10. print(deep_dog_net)
  11.  
  12. out = mx.nd.SoftmaxActivation(net(image.as_in_context(contexts[0])))
  13. print('Probabilities are: '+str(out[0].asnumpy()))
  14. result = np.argmax(out.asnumpy())
  15.  
  16. if np.argmax(out.asnumpy()) == 713:
  17. "Hot Dog!'
  18. Else:
  19. "Not hot dog!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement