itdxer / neupy

NeuPy is a Tensorflow based python library for prototyping and building neural networks
http://neupy.com
MIT License
742 stars 160 forks source link

Feature request: #251

Closed DPR-Sanchez closed 5 years ago

DPR-Sanchez commented 5 years ago

Give plot_optimizer_errors in neupy.algorithms.plot an image flag similar to the show flag that triggers a PIL image to be returned.

location: https://github.com/itdxer/neupy/blob/master/neupy/algorithms/plots.py

itdxer commented 5 years ago

Why do you think that will be useful?

Also, I don't think that the plot_optimizer_errors name will be appropriate in that case, since function won't plot anything

DPR-Sanchez commented 5 years ago

It would be immediately useful to the below project: https://github.com/DPR-Sanchez/neural-net-models/tree/dev

It would allow an image to be obtained that could be utilized by PySimpleGUI (https://github.com/PySimpleGUI/PySimpleGUI)

It would also allow the image to be saved to disk so history could be preserved. This would also enable images saved in such manner to be printed out and utilized on presentation poster boards during research conferences, etc.

I am currently hoping to use it to display the training in a PySimpleGUI canvas object at the moment.

A demo mock-up of what would show if 'Show Training' was clicked:

image

itdxer commented 5 years ago

Why don't you use plt.savefig?

DPR-Sanchez commented 5 years ago

I felt that passing an image object back gave users more flexibility in choosing how they wanted to further process the image, whether that be saving to disk or using it in a canvas.

I also felt that assuming users would want the figure saved to the programs directory with the inability to specify save location was not conducive to user friendliness, and the additional modifications that would need to be made to plot_errors was too much. I tried to minimize the amount that existing methods were changed beyond adding parameters.

itdxer commented 5 years ago

I see your point, but I'm still not sure why do you think it's a general problem? Why don't you just use this code as part of your library? For example:

optimizer.plot_errors(show=False)
fig = plt.gcf()
extract_something_from_figure(fig)

or

optimizer.plot_errors(show=False)
plt.savefig('image.png')
read_image_with_any_library('image.png')
DPR-Sanchez commented 5 years ago

To be honest, I do not think it would be a common general need, but I wanted to help give back to an Open Source project that has been very helpful to me and provide future developers that option by just using a flag. The above code would also address the matter, however.

itdxer commented 5 years ago

I see and I really appreciate that! Very little people try to help and contribute into the open source community.

I'm the only one maintaining this project and it's quite difficult to expand library beyond the necessary things. There are two reasons for that:

  1. The more libraries are included during the installation the harder to maintain the project. It happens usually with new releases, conflicting interests between different libraries or different level of support in different OS. That's why I don't require user to install pandas and scikit-learn (despite that it's used in some places)

  2. Supporting code got pretty difficult and my last big change (starting from version 0.8) required me to remove a lot of the code for this reason. Since then, I try to keep only necessary things in the library.

I would have to reject this feature request and I hope it wouldn't discourage you from contributing to the open source projects.

Thank you for the PR though. In the future, I would suggest discussing these issues before you put your time and work into it (might be a good idea for any general project since some people don't respond to the PR or issues when project is abandoned).