You can see some good example about manipulating Tensorflow C API at:

  
      

      github.com
  

  
    

GitHub - serizba/cppflow: Run TensorFlow models in C++ without installation and... 16


  Run TensorFlow models in C++ without installation and without Bazel - GitHub - serizba/cppflow: Run TensorFlow models in C++ without installation and without Bazel

  

  
    
    
  

  


You can access to layer weights with:

  

      github.com/serizba/cppflow
  

  
    
  
	  
  

  
    
      How to extract weights from saved model? 4
    

    
      
        opened 
        
          
        
        Dec 7, 2020
      
      


      
        
          
          abucka
        
      
    

    
    
  


  
    Hi!

How can I extract weights from the saved model? 

I am looking for the …equivalent of Python model.get_weights() but in Tensorflow C API. Especially, I would like to extract the weights for the last convolutional layer.

Thank you!
  

  

  
    
    
  

  


If you want to use instead  TFlite or TFlite Micro for inference they already have their own c++ API documented.
But to manipulate TFlite weights for inference you could check:

  

      github.com/tensorflow/tensorflow
  

  
    
  
	  
  

  
    
      How to modify weights in TFLite model and check effect on activation layer output, set_tensor helps only on input layers and not intermediate tensors. 2
    

    
      
        opened 
        
          
        
        May 3, 2021
      
      

        
          closed 
        
          
        
        May 21, 2021
      
        

      
        
          
          manp-git
        
      
    

    
        stat:awaiting response
        type:support
        stalled
        comp:lite
        TF 2.0
    
  


  
    How to modify weights in TFLite model and check effect on activation layer outpu…t for experimentation purpose, set_tensor helps reapply things only on input layers and not intermediate tensors.
I am ok doing in offline by extracting output of previous layer and convolving it with the extracted weights and biases of layer in consideration. 
Please share if there is a command for that. Else how can I exactly replicate the convolution and activation process of that particular Resnet50 layer outside the model using python etc.
Using standard Resnet50- keras model, quantised by TFLite converter.

Targetting conv2_block1_2 for experimentation; able to extract output of previous conv block which is input to this (conv2_block1_1) along with weights (ReadVariableOp) and bias of conv2_block1_2 from the TFLite model.

Tensorflow 2.0
  

  

  
    
    
  

  


To just read weights in TFlite c++:

  

      stackoverflow.com
  

  
      
    
  


  How to get weights in tflite using c++ api? 5



  tensorflow-lite



  asked by
  
  
    马嘉林
  
  on 08:08AM - 21 May 20 UTC