My cost function involves the matrix
T=[[1.0-a,b],[a,1.0-b]]
I can define
import numpy as np
import tensorflow as tf
a=0.3
b=0.4
T = tf.Variable([[1.0-a,b],[a,1.0-b]]
and this works well in the optimization, but then I am saying that I have four variables: 1-a,b,a,1-b (the gradient has four elements). On the other hand, I would like my variables to be two: a and b (the gradient has two elements).
I thought of doing something like
var = tf.Variable([a,b])
T = tf.constant([[1.0-var[0],var[1]],[var[0],1.0-var[1]]])
but this does not work, outputing the following:
TypeError: List of Tensors when single Tensor expected
So how can I construct a tensor made of tf.Variable objects?
Thank you.
T=[[1.0-a,b],[a,1.0-b]]? In what sense is this a cost function?