Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find a class or function in a Python module?

I'm trying to find the function or class definition of gen_dataset_ops in tensorflow, which has its sourcecode here. I find many places where it is imported like so:

from tensorflow.python.ops import gen_dataset_ops

But I can't find where it is defined, I'd expect to find something like:

def gen_dataset_ops(...):
  #Do something clever
  return

I don't quite understand the anatomy of python modules in general, so I'm probably missing some basics here,.. any hint is welcome!

like image 905
Bastiaan Avatar asked Feb 25 '26 14:02

Bastiaan


1 Answers

tensorflow.python.ops.gen_dataset_ops is generated code. (That's why they put gen in front of the name.) You can't find it in the source repository because it's not in the source repository; it only comes into existence during the Tensorflow build process.

If you have Tensorflow installed, you should be able to find gen_dataset_ops.py under tensorflow/python/ops/gen_dataset_ops.py in your Tensorflow installation.

like image 73
user2357112 supports Monica Avatar answered Feb 27 '26 03:02

user2357112 supports Monica