NetLogo / Python-Extension

Python extension for NetLogo
26 stars 15 forks source link

simple digit recognition #10

Closed robertjankowski closed 5 years ago

robertjankowski commented 5 years ago

Demo of digits recognition task. I use pretrained model on MNIST dataset.

robertjankowski commented 5 years ago

Simple UI ui

LaCuneta commented 5 years ago

Thank you for the pull request! We appreciate it. We think this is a good example model for using NetLogo and Python together, and we have a few comments for you.

One item is on the Info Tab, which at the moment is mostly empty. It'd be good to fill in as much detail as you were able to. You can look at other example models in the NetLogo library for how we usually fill them out. In particular with this model, it'd be important to note the Python libraries used and what they're for.

There were also some code changes:

to-report predict
  py:set images (list map (range max-pycor (min-pycor - 1) -1) [ row ->
    map (range min-pxcor (max-pxcor + 1)) [ col ->
      [ pcolor / 10 ] of patch row col
    ]
  ])
  report py:runresult "model.predict(np.array(images))[0]"
end

Thanks, again!

robertjankowski commented 5 years ago

ui

Changes:

robertjankowski commented 5 years ago

Thanks for your review. I really appreciate it. I added monitors for handling probabilities from softmax layer and fixed other issues.

robertjankowski commented 5 years ago

ui

qiemem commented 5 years ago

Oh, one more quick comment (feel free to ignore). You might consider swapping out the NN model for a fully convolutional one (so, no Dense layers). Right now, performance suffers when the digit is too far left or right. For instance, try drawing a straight line near the right or left side. It will register as a 4 or a 6 instead of a 1. A fully convolutional network should fix that. Maybe something like adding another conv layer or two on and then finish up with a global avg pooling layer with a softmax activation.

robertjankowski commented 5 years ago

I just added fixes. Referring to the model I think maybe in couple of days I would try to improve NN architecture. Many thanks for your help!

LaCuneta commented 5 years ago

This looks good to me. @qiemem, @robertjankowski: Any further changes, or are we good to merge?

robertjankowski commented 5 years ago

For me PR is ready to merge.