• jmv38

    update: i have made a Layer class to more easily add layers. I have now 4 layers. It seems to work, but i have not checked if the undeground maths are correct. I’ve assumed your formula to backpropagate the error is recursive.
    With this implementation you can use the number of layers you want, with the number of neurons you want inside.


    posted in Pythonista read more
  • jmv38

    @mkeywood really having fun with your code, thanks so much for sharing!
    Now i made some more changes: using 2 neurons in the output, to get independant estimates and reliability (and also to see the result with a 3rd template that is not 1 or 2).
    I have also added a small rotation in the training, and tweeked a little bit the training parameters.

    posted in Pythonista read more
  • jmv38

    I have changed the learning rate to 0.02 and increased the number of training epochs to 200: i am getting good results now.

    posted in Pythonista read more
  • jmv38

    @mkeywood i have tried to add some robustness: i shift the drawings in 9 position for the training. I had to decrease the learning rate by x0.1. Is it ok? what do you think?
    Not sure the performance is better.

    note: I also changed the layout because i work in landscape.


    posted in Pythonista read more
  • jmv38

    @mkeywood thank you! Incredible that it is so simple to make some NN. You demystified it.
    How can you add layers?
    Can you make CNN too?

    posted in Pythonista read more
  • jmv38

    here is another video, technically more useful

    posted in Pythonista read more
  • jmv38

    ok i got it. numpy.save cannot decode tuples by itself...
    surprising that there is no simple way to save a structured array, and that i must flatten the structure to save it. Extra work and risk of errors... Anyway...

    posted in Pythonista read more
  • jmv38

    still in trouble.
    I am trying to save my numpy structured array with np.save, here is the code for details

    # differents tests avec Luv
    from labColor import *
    import numpy as np
    from console import clear
    # compute all colors
    def getAllColors(step):
      dtype = [('L', float), ('u', float), ('v', float), ('c', tuple), ('d', float)]
      data = []
      for r in np.arange(0, 256, step):
        for g in np.arange(0, 256, step):
          for b in np.arange(0, 256, step):
            L, u, v = rgb_to_sLuv(r, g, b)
            data.append((L, u, v, (r/255,g/255,b/255), 0.0))
      ar = np.array(data,dtype=dtype)
      return ar
    ar = getAllColors(50)
    a = np.load('rgb.npy')

    but i get this error

    Traceback (most recent call last):
      File "/private/var/mobile/Containers/Shared/AppGroup/..../Pythonista3/Documents/couleurs/labColor6.py", line 24, in <module>
      File "/var/containers/Bundle/Application/..../Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/numpy/lib/npyio.py", line 451, in save
        format.write_array(fid, arr)
      File "/var/containers/Bundle/Application/.../Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/numpy/lib/format.py", line 407, in write_array
        pickle.dump(array, fp, protocol=2)
    _pickle.PicklingError: Can't pickle <built-in function _reconstruct>: import of module 'multiarray' failed

    what am i doing wrong?

    posted in Pythonista read more
  • jmv38

    @mikael actually
    1/ i have not computed enough intermediate frames (each take 30s on my ipad air)
    2/ i use the video to view it frame by frame from the ipad photo roll, to turn around as i wish, so it is enough for my usage
    3/ i have tried 0.5s once but it skipped 1 frame in the middle, so i thought i would remain at 1 Hz.

    posted in Pythonista read more
  • jmv38

    here is the code

    import ui
    from console import clear
    from PIL import Image
    import io as io
    def pil2ui(pil_img):
        with io.BytesIO() as buffer:
            pil_img.save(buffer, format='PNG')
            return ui.Image.from_data(buffer.getvalue())
    class MyView (ui.View):
      def __init__(self):
        # global view settings
        self.name = 'Viewing where colors lie in the CIE L*u*v* color space'                                    
        self.background_color = 'gray'     
        # trying to update 1 per second
        self.update_interval = 1
        # image settings
        img = ui.Button(name='image')
        img.width = 1476/1.5
        img.height = 1024/1.5
        img.enable = False
        img.hidden = False
        self.img = img
        # add a copyright
        txt = ui.Label()
        txt.text = 'copyright JMV38 2019'
        txt.text_color = (0.5, 0.5, 0.5, 0.2)
        txt.width = 600
        txt.height = 100
        txt.alignment = ui.ALIGN_CENTER
        fontName, fontSize = txt.font
        txt.font = (fontName,30)
        self.txt = txt
      def update(self):
        self.img.center = (self.width * 0.5, self.height * 0.5)
        self.txt.center = (self.width * 0.5, self.height * 0.5)
          self.azim -= 10
          self.azim = 180
        file = 'CieLuv_'+str(self.azim)+'.png'
          im = Image.open(file)
          ui_image = pil2ui(im)
          self.img.background_image = ui_image
    if __name__ == '__main__':
      view = MyView()      

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!