trigeorgis / mdm

A TensorFlow implementation of the Mnemonic Descent Method.
BSD 3-Clause "New" or "Revised" License
124 stars 48 forks source link

Replacing Custom Tensorflow Operation #11

Closed tuckerdarby closed 7 years ago

tuckerdarby commented 7 years ago

Hi trigeorgis,

Instead of installing your custom TF repo to gain the custom extract image patches operation, I tried to write the operation in python with TF 1.0. This is what I came up with:

`

        unset_patches = []
        for offset in tf.unstack(inits+dx, axis=1):
            batch_patches = tf.image.extract_glimpse(images, patch_shape, offset)
            unset_patches.append(batch_patches)
        # patches = tf.transpose(unset_patches, (1, 0, 2, 3, 4))
        patches = tf.stack(unset_patches, axis=1)
        patches = tf.reshape(patches, (batch_size * num_patches, patch_shape[0], patch_shape[1], num_channels))`

From here training is able to run, but no learning takes place and losses hover around 1.0 for thousands of steps.

Is there something I'm missing with this? Perhaps the optimizer can't back propagate losses through the operations taking place in python here, or there's an error in the code above when extracting and stacking these patches?

Let me know if you'd like any more information.

Help is greatly appreciated!

trigeorgis commented 7 years ago

I began writing some code which does not rely on custom c++ ops that's in https://github.com/trigeorgis/mdm/tree/refactored so you can have a look at that.