Create class object with a tuple having tensorflow objects

40 views Asked by At

I have a parametersTheta class which creates neural network as follows:

class parametersTheta:
    def __init__(self, weight1, weight2,....):
        self.weightName1 = weight1
        self.weightName2 = weight2
        ...
        self.sess = tf.Session()
    def makeWorkerTheta(self, param):
        return parametersTheta(self.sess.run(functionCalculatingTensorWeights, feed_dict={...}))

self.sess.run creates a tuple of all the weight tensors. However, error pops up saying you need to input weight2 and onwards, i.e. the tuple goes into weight1

How can I solve this? Basically, how can I create an instance of class parametersTheta with a tuple?

1

There are 1 answers

0
T. Ogawa On BEST ANSWER

You can instantiate class with tuple expanded to arguments like this.

parametersTheta(*(weight1, weight2, ...))

An asterisk before a tuple expand it to a corresponding arguments list.