xxxxxxxxxx
import numpy
A=numpy.array(range(1,9)).reshape(2,2,2)
B=['A','B','C','D']
B=numpy.array(B,dtype=object).reshape(2,2)
AB1=numpy.tensordot(A,B,1)
AB01=numpy.tensordot(A,B,(0,1))
AB10=numpy.tensordot(A,B,(1,0))
def pp(string,color):
start='<text style="color:'+color
start+=';">${\\mathbb{'
end='}}$</text>'
return display(html(start+string+end))
def result(X):
pretty_print(X.shape)
for i in range(2):
for j in range(2):
for k in range(2):
pp(X[i,j,k],'darkblue')
result(AB1); result(AB01); result(AB10)
No comments:
Post a Comment