In [39]:
import tensorflow as tf
a = tf.constant([1.0, 2.0])
b = tf.constant([3.0, 10.0])
c = a * b

emitX=tf.constant([3.])
emitY=tf.constant([4.])
emitZ=tf.constant([5.])


with tf.Session() as sess:
    print "OK"
    print sess.run(tf.eye(6))
    
    print sess.run(tf.eye(6)*tf.diag([tf.sqrt(emitX[0]),tf.sqrt(emitX[0]),tf.sqrt(emitY[0]),tf.sqrt(emitY[0]),tf.sqrt(emitZ[0]),tf.sqrt(emitZ[0])]))


OK
[[ 1.  0.  0.  0.  0.  0.]
 [ 0.  1.  0.  0.  0.  0.]
 [ 0.  0.  1.  0.  0.  0.]
 [ 0.  0.  0.  1.  0.  0.]
 [ 0.  0.  0.  0.  1.  0.]
 [ 0.  0.  0.  0.  0.  1.]]
[[ 1.73205078  0.          0.          0.          0.          0.        ]
 [ 0.          1.73205078  0.          0.          0.          0.        ]
 [ 0.          0.          2.          0.          0.          0.        ]
 [ 0.          0.          0.          2.          0.          0.        ]
 [ 0.          0.          0.          0.          2.23606801  0.        ]
 [ 0.          0.          0.          0.          0.          2.23606801]]

In [52]:
def  layerTwiss(energyIn,emitX,emitY,emitZ, numPart):
    Werights=tf.Variable(tf.eye(6))
    covT=Werights*tf.diag([tf.sqrt(emitX[0]),tf.sqrt(emitX[0]),tf.sqrt(emitY[0]),tf.sqrt(emitY[0]),tf.sqrt(emitZ[0]),tf.sqrt(emitZ[0])])
    
    return covT

def Tmp(emitX,emitY,emitZ):
    Werights=tf.Variable(tf.eye(6))
    return Weights

In [54]:
import tensorflow as tf

energyIn=tf.constant(10.)
emitX=tf.constant([3.])
emitY=tf.constant([4.])
emitZ=tf.constant([5.])
numPart=tf.constant(1000.)

def Tmp(emitX,emitY,emitZ):
    Werights=tf.Variable(tf.eye(6))
    return Weights

with tf.Session() as sess:
     sess.run(Tmp(emitX,emitY,emitZ))


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-54-f0e7d42afed9> in <module>()
     10 
     11 with tf.Session() as sess:
---> 12      sess.run(Tmp(emitX,emitY,emitZ))

<ipython-input-54-f0e7d42afed9> in Tmp(emitX, emitY, emitZ)
      7 def Tmp(emitX,emitY,emitZ):
      8     Werights=tf.Variable(tf.eye(6))
----> 9     return Weights
     10 
     11 with tf.Session() as sess:

NameError: global name 'Weights' is not defined

In [ ]:


In [ ]: