0

Let say I have this pseudocode:

Receive input from a user.
Depending on the input value do separate procedures.

Here is the MWE I have:


class vgg_16_cnn:
      def __init__(self, mode):
           self.mode = mode
      if self.mode.tolower == "tensorflow":
           #################################################
           #
           #         Do Tensorflow procedure
           #
           #################################################
      if self.mode.tolower == "pytorch":
           #################################################
           #
           #         Do pytorch procedure
           #
           #################################################
mode_init = str(input("What mode are you processing the data: ")) ## Possible answers Tensorflow and Pytorch
machine_learning_alg = vgg_16_cnn(mode="tensorflow")

In my MWE is where I kind of get lost so bare with me. Is it possible to have these two states exist in the same class I could function overload, like in Java(except its methods).

EnlightenedFunky
  • 303
  • 1
  • 13
  • 1
    frame challenge: instead of having one class with two different behaviors, have one parent class (which might be abstract) and two child classes, one for each behavior (e.g. `vgg_16_cnn_tf` and `vgg_16_cnn_pytorch`). That way they can be treated the same by all calling code, except for when one of them is chosen over the other initially. – Green Cloak Guy Nov 02 '21 at 13:33
  • @GreenCloakGuy Ok Inheritance cool do you have references which I could use because I have a bigger code for the tensorflow class already, I just need to program the pytorch class. – EnlightenedFunky Nov 02 '21 at 13:35
  • I think these will help : - [Is it possible to make abstract classes in Python?](https://stackoverflow.com/questions/13646245/is-it-possible-to-make-abstract-classes-in-python) - [Writing abstract methods with parameters](https://blog.teclado.com/python-abc-abstract-base-classes/) – Vaggelis_Lazarakis Nov 02 '21 at 13:58

0 Answers0