Skip to content

Example of 'Transfer Learning' on multiple layers with TensorFlow.NET #248

Open

Description

@CESARDELATORRE

I was checking out the TensofFlow samples available in the repo but looks like in all of them (Image Classification, Object Detection) the samples are just running/scoring pre-trained TensorFlow models such as Inception v3:

https://github.com/SciSharp/TensorFlow.NET/blob/master/test/TensorFlowNET.Examples/ImageProcess/ImageRecognitionInception.cs

https://github.com/SciSharp/TensorFlow.NET/blob/master/test/TensorFlowNET.Examples/ImageProcess/InceptionArchGoogLeNet.cs

https://github.com/SciSharp/TensorFlow.NET/blob/master/test/TensorFlowNET.Examples/ImageProcess/ObjectDetection.cs

Do you support more advanced scenarios such as:

Do you have (is it possible with TensorFlow.NET?) any example on how to do 'Transfer Learning' with TensorFlow.NET such as training with new images on the final layer and even on multiple layers (and ultimately possibility for the full network) of the TF network?

The following is a basic 'Transfer Learning' sample using Keras/Python.

https://github.com/dotnet-architecture/eShopOnContainersAI/blob/dev/workbench/keras_training.py

I mean something comparable to that but using TensorFlow.NET.

Thanks! :)

Activity

  1. self-assigned this
    on May 17, 2019
  2. added
    enhancement
    on May 17, 2019
  3. Oceania2018 commented on May 17, 2019

    @Oceania2018
    Member

    @CESARDELATORRE Absolutly tf.net can train and predict image. I'll try my best to do an example for your case and upload to Example project. Please check the RetrainImageClassifier example. It's not finished yet currently.

  4. Oceania2018 commented on May 24, 2019

    @Oceania2018
    Member

    @CESARDELATORRE The Transfer Learning example is finished. Let me know if you have any question.

  5. CESARDELATORRE commented on May 24, 2019

    @CESARDELATORRE
    Author

    @Oceania2018 - Cool! - I'll learn about it as soon as possible!
    Btw, I was just testing the samples and it gave me an error/exception in VS when running the samples, here:

    image

    System.Exception
    HResult=0x80131500
    Message=SemanticPredictions:0 is both fed and fetched.
    Source=TensorFlow.NET
    StackTrace:
    at Tensorflow.Status.Check(Boolean throwException) in D:\GitRepos\TensorFlow.NET\src\TensorFlowNET.Core\Status\Status.cs:line 48
    at Tensorflow.BaseSession._call_tf_sessionrun(KeyValuePair2[] feed_dict, TF_Output[] fetch_list, List1 target_list) in D:\GitRepos\TensorFlow.NET\src\TensorFlowNET.Core\Sessions\BaseSession.cs:line 214
    at Tensorflow.BaseSession._do_run(List1 target_list, List1 fetch_list, Dictionary2 feed_dict) in D:\GitRepos\TensorFlow.NET\src\TensorFlowNET.Core\Sessions\BaseSession.cs:line 189 at Tensorflow.BaseSession._run(Object fetches, FeedItem[] feed_dict) in D:\GitRepos\TensorFlow.NET\src\TensorFlowNET.Core\Sessions\BaseSession.cs:line 142 at Tensorflow.BaseSession.run(Object fetches, FeedItem[] feed_dict) in D:\GitRepos\TensorFlow.NET\src\TensorFlowNET.Core\Sessions\BaseSession.cs:line 45 at TensorFlowNET.Examples.ImageProcess.ImageBackgroundRemoval.<>c__DisplayClass15_0.<Run>b__0(Session sess) in D:\GitRepos\TensorFlow.NET\test\TensorFlowNET.Examples\ImageProcess\ImageBackgroundRemoval.cs:line 42 at Tensorflow.Python.with[T](T py, Action1 action) in D:\GitRepos\TensorFlow.NET\src\TensorFlowNET.Core\Python.cs:line 88

  6. Oceania2018 commented on May 25, 2019

    @Oceania2018
    Member

    Seems like you’re running a unfinished example: TensorFlowNET.Examples.ImageProcess.ImageBackgroundRemoval.

  7. CESARDELATORRE commented on May 25, 2019

    @CESARDELATORRE
    Author

    I'm running the whole project from VS. It'd be good to either split the samples or to comment the call invoking a sample that is not finished?

  8. Oceania2018 commented on May 25, 2019

    @Oceania2018
    Member

    Check this file: https://github.com/SciSharp/TensorFlow.NET/blob/master/test/TensorFlowNET.Examples/Program.cs, you can pass example.Name to run specific example only.

  9. PranovD commented on Jun 11, 2019

    @PranovD

    image
    File RetrainImageClassifier.cs Line 362

    I am getting an error about InceptionV3.meta not being loadable due to mismatched attributes. I believe this is a issue with using InceptionV3.meta on any version of TensorFlow higher than 1.4 (I am using 1.13 from the documentation), do you know of a work around?

    tensorflow/models#4093

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions