NeuraLegion / shainet

SHAInet - a pure Crystal machine learning library
MIT License
181 stars 19 forks source link

Help building Cats vs Dogs CNN network #92

Closed drujensen closed 4 years ago

drujensen commented 4 years ago

I have been playing with the CNN network trying to get any results but continue to hit roadblocks and I'm hoping to get some help.

I first converted the images to 48x48x1 greyscale to try and keep things as simple as possible.

I built a network as follows:

Dimensions
layers x width x height x channels
==================================
SHAInet::InputLayer
1 x 48 x 48 x 1
----------------------------------
SHAInet::ConvLayer
20 x 48 x 48 x 1
----------------------------------
SHAInet::MaxPoolLayer
20 x 24 x 24 x 1
----------------------------------
SHAInet::ConvLayer
20 x 24 x 24 x 20
----------------------------------
SHAInet::MaxPoolLayer
20 x 12 x 12 x 1
----------------------------------
SHAInet::FullyConnectedLayer
1 x 12 x 1 x 1
----------------------------------

I have tried many different configurations for training the model but all seem to error out:

model.train_batch(
  data: training.data_pairs,
  training_type: :sgdm,
  cost_function: :mse,
  epochs: 25,
  error_threshold: 0.0001,
  log_each: 100,
  mini_batch_size: 32)

No matter what I try, I get:

I, [2019-11-02 09:35:25 -07:00 #56315]  INFO -- : Epoch: 0, Total error: 1.0, MSE: 1.0

Here is the project: https://github.com/drujensen/cats_dogs

Any ideas?

drujensen commented 4 years ago

closing... I think I tracked it down.

bararchy commented 4 years ago

@drujensen what was it?

drujensen commented 4 years ago

I had the wrong data structure for the inputs: Array(Array(Array(Array(Float64)))). I was doing Images / Rows / Columns / Channels but it needs to be Images / Channels / Rows / Columns. I am still trying to train the model but at least I am getting results.

bararchy commented 4 years ago

@drujensen I'm happy to hear you're making progress, I think I'll take the next weekend to add some MT support to SHAInet, it would be a bit of a hard task as most vars are instance shared so in a Multi-Fiber environment lots of Mutexes will be used, I'll see if I can do it without breaking the whole project down :) that would make the training faster

ArtLinkov commented 4 years ago

@drujensen I would also love to hear about your progress, and if you feel like the SHAInet CNN is giving you what you need for your project :slightly_smiling_face: