Recent

Author Topic: Conscious Artificial Intelligence - Project Update  (Read 12116 times)

agorka

  • New Member
  • *
  • Posts: 22
Re: Conscious Artificial Intelligence - Project Update
« Reply #60 on: January 21, 2020, 11:01:09 am »
Hello!
I've got some news on my progress porting Keras model to your library!
I've finally trained it in Keras to 95% accuracy, tried to use it in Pascal, and faced this problem:

My model looks like
Code: Pascal  [Select]
  1.       TNNetInput.Create(512, 128, 1),
  2.       TNNetConvolutionReLU.Create(24, 7, 0, 1, 0).InitUniform(0),
  3.       TNNetConvolutionReLU.Create(24, 5, 0, 1, 0).InitUniform(0),
  4.       TNNetMaxPoolPortable.Create(2, 2),
  5.       TNNetConvolutionReLU.Create(24*2, 5, 0, 1, 0).InitUniform(0),
  6.       TNNetMaxPoolPortable.Create(2, 2),
  7.       TNNetConvolutionReLU.Create(24*4, 5, 0, 1, 0).InitUniform(0),
  8.       TNNetMaxPoolPortable.Create(2, 2),
  9.       TNNetConvolutionReLU.Create(24*4, 5, 0, 1, 0).InitUniform(0),
  10.       TNNetMaxPoolPortable.Create(2, 2),
  11.       TNNetFullConnectLinear.Create(NumClasses)
Seems that X and Y coordinates are swapped when loading Conv layer weights from strings saved in Keras.
I found that by looking to feature maps, Keras contained vertical lines while pascal contained horizontal and vise versa. I used numpy.swapaxes on weights for convolution layers and it did the trick, though images are still not 100% the same, maybe I'll also need to flip convolution filters to match with Keras.
The next problem was the dense layer.
In Keras I had a flatten layer before the dense, so weights of the dense layer were flat. I had to reshape them manually to 27x3x96, swap axes, flatten, and then save. This seems too cumbersome, cause I had to know the original image shape, and it can't be used in generic weight saving function...
Having non-square convolution could have solved my problem, so I could use 27x3 convolution instead of dense layer.
Maybe you have a better different idea how this problem could be solved in a more beautiful way?

Good news is that after all those tricks I've got very good prediction accuracy in Pascal! Thank you again for making this possible! =)
Oleg.