microsoft / EdgeML

This repository provides code for machine learning algorithms for edge devices developed at Microsoft Research India.
Other
1.59k stars 370 forks source link

How to get predictions from trained model for FastCells in Tensorflow #253

Closed swapnilsayansaha closed 2 years ago

swapnilsayansaha commented 2 years ago

For Bonsai and ProtoNN, we can convert the trained TF model to tflite and perform inference on new data. I was wondering if something similar exists for FastCells in TF, where we could load the pre-trained model parameters and perform inference (maybe not through TFLite but through TF directly).

P.S. I could've used Seedot to compile FastCells but right now it has some bugs that prevent its compilation for custom FastCells models. #251

ShikharJ commented 2 years ago

@adityakusupati Can you please take a look?

adityakusupati commented 2 years ago

Hi,

The same sort of inference should work for FastCells too however, this is all in tf 1.0 which has limited support.

You can use see dot to automatically compile low level code files for inference.

Hope this helps.

On Sat, Jan 29, 2022, 4:47 AM Shikhar Jaiswal @.***> wrote:

@adityakusupati https://github.com/adityakusupati Can you please take a look?

— Reply to this email directly, view it on GitHub https://github.com/microsoft/EdgeML/issues/253#issuecomment-1024905412, or unsubscribe https://github.com/notifications/unsubscribe-auth/AECUG3PZDXDWUSIJCPXBYT3UYPOXHANCNFSM5NBPUSFQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

swapnilsayansaha commented 2 years ago

Seedot has some issues converting models trained on custom dataset #251

Anyways I exposed the predictions from the training script:

In fastTrainer.py, in the train function:

 testAcc, testLoss, s_predictions, s_truth = sess.run([self.accuracy, self.lossOp, self.Y_output, self.Y_truth], feed_dict={
                                         self.X: Xtest, self.Y: Ytest})

            print('s_predictions:', s_predictions) #model predictions
            print('s_truth:', s_truth) #ground truth labels

in the init() function:

        self.Y_output = tf.argmax(self.predictions, 1)
        self.Y_truth = tf.argmax(self.Y, 1)