15. Generic Tensor Fitting¶
quimb
has support for fitting arbitrary tensor networks to other tensors or tensor networks.
Here we show decomposing a 4-tensor into a ring.
%config InlineBackend.figure_formats = ['svg']
import numpy as np
import quimb.tensor as qtn
Create a target 10x10x10x10 tensor with uniform positive entries:
t_target = qtn.Tensor(
data=np.random.uniform(size=(10, 10, 10, 10)),
inds=('a', 'b', 'c', 'd'),
)
t_target
Tensor(shape=(10, 10, 10, 10), inds=[a, b, c, d], tags={}),
backend=numpy, dtype=float64, data=array([[[[0.25445712, 0.47469735, 0.39981281, ..., 0.43891985, 0.58686573, 0.65375743], [0.08347051, 0.98621559, 0.46709151, ..., 0.0231914 , 0.66753566, 0.13932313], [0.48101021, 0.74136389, 0.81019999, ..., 0.84022567, 0.08874621, 0.99325861], ..., [0.6406165 , 0.22321876, 0.61248516, ..., 0.43907654, 0.4690423 , 0.35141222], [0.02473146, 0.15817392, 0.60624129, ..., 0.71510966, 0.13007749, 0.43013948], [0.46945405, 0.89820152, 0.22921834, ..., 0.36976807, 0.41358485, 0.81546414]], [[0.79135875, 0.54475247, 0.09735291, ..., 0.12175049, 0.20826509, 0.57160829], [0.49750624, 0.25581166, 0.24807838, ..., 0.00550824, 0.15176781, 0.30426552], [0.41174337, 0.95268263, 0.04315 , ..., 0.10649929, 0.27707141, 0.51314964], ..., [0.63333041, 0.77544186, 0.88424645, ..., 0.58963534, 0.82293401, 0.76194322], [0.91983987, 0.33227442, 0.01686932, ..., 0.39135873, 0.35814929, 0.59023438], [0.47927572, 0.53976617, 0.60652352, ..., 0.69664789, 0.84208529, 0.934776 ]], [[0.80616749, 0.8932247 , 0.48673082, ..., 0.05398075, 0.92994083, 0.52116732], [0.99980569, 0.1636051 , 0.6180379 , ..., 0.74719056, 0.26968389, 0.71713385], [0.13042623, 0.20026309, 0.83921683, ..., 0.35132347, 0.22941345, 0.66750334], ..., [0.6875798 , 0.96271119, 0.07892669, ..., 0.91311501, 0.52394436, 0.32249404], [0.06386469, 0.50134967, 0.85144808, ..., 0.83182177, 0.67854213, 0.36391634], [0.262442 , 0.93598076, 0.36603079, ..., 0.11455229, 0.85342355, 0.3138073 ]], ..., [[0.01466219, 0.48385041, 0.97574704, ..., 0.63001849, 0.55107114, 0.5182148 ], [0.83768626, 0.80618638, 0.08807806, ..., 0.74902942, 0.41069094, 0.97623288], [0.56984555, 0.33807075, 0.56774416, ..., 0.47581327, 0.05318293, 0.38681688], ..., [0.76637906, 0.45200776, 0.76377105, ..., 0.12956966, 0.62295023, 0.73518882], [0.07843119, 0.03782661, 0.32369759, ..., 0.2670686 , 0.62644612, 0.06744153], [0.32343986, 0.49773808, 0.37366589, ..., 0.24845288, 0.41851664, 0.21076671]], [[0.17759998, 0.35321382, 0.05050006, ..., 0.95464803, 0.3671227 , 0.65003031], [0.17672535, 0.9312092 , 0.00777363, ..., 0.38058356, 0.28949829, 0.39408565], [0.5412085 , 0.59423202, 0.83901817, ..., 0.94889701, 0.78412729, 0.3362738 ], ..., [0.59962378, 0.64929775, 0.04637884, ..., 0.56858993, 0.2268177 , 0.7182477 ], [0.71243268, 0.67891995, 0.48330483, ..., 0.4305374 , 0.22547455, 0.22533932], [0.69661364, 0.07268062, 0.60126948, ..., 0.34596386, 0.98990696, 0.76832779]], [[0.77569276, 0.24365824, 0.76688183, ..., 0.93173384, 0.13475432, 0.29636577], [0.70967942, 0.08716175, 0.7552589 , ..., 0.0037271 , 0.0023108 , 0.07657197], [0.01838135, 0.55607397, 0.3349065 , ..., 0.81681267, 0.13896205, 0.47802673], ..., [0.16433886, 0.44363091, 0.95313612, ..., 0.90210831, 0.03821925, 0.98866381], [0.39007775, 0.19180256, 0.15213682, ..., 0.14606696, 0.75401051, 0.77376029], [0.36303734, 0.94523796, 0.16900005, ..., 0.73706475, 0.55970977, 0.50127406]]], [[[0.98814526, 0.30724063, 0.84309796, ..., 0.42476504, 0.88928931, 0.92754083], [0.23712863, 0.58879351, 0.8220058 , ..., 0.01875346, 0.17147879, 0.02551551], [0.59599768, 0.30469225, 0.71915442, ..., 0.83380629, 0.18506268, 0.58903077], ..., [0.43783671, 0.0013524 , 0.44417045, ..., 0.79851586, 0.12355301, 0.87600913], [0.81257528, 0.6185347 , 0.9711484 , ..., 0.94793323, 0.7965852 , 0.8235594 ], [0.09391816, 0.52605347, 0.80080389, ..., 0.60936759, 0.11988464, 0.21546633]], [[0.89670805, 0.53187666, 0.33493337, ..., 0.69360359, 0.04176366, 0.15435867], [0.41958272, 0.12468762, 0.67643752, ..., 0.80826413, 0.28977174, 0.74908175], [0.31872317, 0.62864645, 0.41465361, ..., 0.32408562, 0.06250183, 0.46927633], ..., [0.4582175 , 0.29911945, 0.69124212, ..., 0.23912283, 0.65982244, 0.08799892], [0.22242399, 0.13211488, 0.62548587, ..., 0.92820183, 0.59451939, 0.42911597], [0.45390228, 0.79507004, 0.25820992, ..., 0.9758698 , 0.48914368, 0.04169531]], [[0.25165747, 0.82530847, 0.95712487, ..., 0.49230451, 0.2300629 , 0.9887231 ], [0.67895386, 0.00956628, 0.76118223, ..., 0.37160968, 0.85231818, 0.35159725], [0.73885784, 0.62849222, 0.04297852, ..., 0.70011537, 0.21075218, 0.04547122], ..., [0.47960009, 0.69662849, 0.34804486, ..., 0.32204786, 0.61490193, 0.39563889], [0.57622556, 0.54542487, 0.17146274, ..., 0.10206162, 0.98803419, 0.64667866], [0.31359383, 0.67620313, 0.66966721, ..., 0.42743951, 0.25554872, 0.43271208]], ..., [[0.74171555, 0.64789028, 0.94325447, ..., 0.01214056, 0.51778411, 0.87929378], [0.98674256, 0.24661631, 0.60937522, ..., 0.5625301 , 0.64345466, 0.58313415], [0.50508425, 0.29280112, 0.26341524, ..., 0.26757695, 0.12520174, 0.58316722], ..., [0.35052986, 0.68190337, 0.05945893, ..., 0.90009995, 0.29157474, 0.05936252], [0.29179999, 0.62856398, 0.12698198, ..., 0.76438843, 0.15977681, 0.58682191], [0.61093842, 0.72613787, 0.13510483, ..., 0.83016192, 0.69070064, 0.1004943 ]], [[0.57302018, 0.00480509, 0.02267172, ..., 0.38924379, 0.1614764 , 0.36963632], [0.16257412, 0.04960957, 0.94338394, ..., 0.1478407 , 0.53375951, 0.6603059 ], [0.50369048, 0.24107558, 0.57652443, ..., 0.42528382, 0.20208629, 0.51870751], ..., [0.28609961, 0.64947787, 0.95986917, ..., 0.03077408, 0.24052222, 0.03383462], [0.48909504, 0.52578428, 0.62815195, ..., 0.9920767 , 0.18724944, 0.31123178], [0.95876527, 0.05755633, 0.14544017, ..., 0.91823226, 0.95941961, 0.31156067]], [[0.32627376, 0.35742444, 0.51117277, ..., 0.40471803, 0.94772867, 0.05397924], [0.64048142, 0.42383376, 0.87442974, ..., 0.66075182, 0.60877312, 0.68808397], [0.10604535, 0.28199175, 0.73673726, ..., 0.50796287, 0.04160674, 0.70613007], ..., [0.52165365, 0.41307941, 0.86402063, ..., 0.40219411, 0.67982647, 0.2971535 ], [0.49792088, 0.09353234, 0.25683488, ..., 0.15322855, 0.28793571, 0.34209748], [0.22863485, 0.54239697, 0.14809588, ..., 0.39586207, 0.59240283, 0.41936045]]], [[[0.73451446, 0.88040783, 0.9063857 , ..., 0.41853091, 0.43746252, 0.41888343], [0.00947969, 0.52404499, 0.76830348, ..., 0.95248584, 0.13779094, 0.65146086], [0.18555196, 0.65107065, 0.01596383, ..., 0.73387565, 0.17080984, 0.16832719], ..., [0.76845857, 0.58209482, 0.07907108, ..., 0.15569885, 0.46701051, 0.29385092], [0.17334355, 0.16423086, 0.54491563, ..., 0.25322832, 0.5964685 , 0.36340873], [0.47375719, 0.54989826, 0.46975387, ..., 0.65876016, 0.99280815, 0.87320974]], [[0.37600731, 0.84712851, 0.90472542, ..., 0.72923314, 0.24390776, 0.88610551], [0.23874797, 0.90894075, 0.64817459, ..., 0.74852521, 0.57176566, 0.8915898 ], [0.98856136, 0.54752667, 0.51135411, ..., 0.69457489, 0.07394581, 0.16028913], ..., [0.01424048, 0.02539665, 0.38627589, ..., 0.35977165, 0.36674667, 0.25424932], [0.98644347, 0.15970818, 0.45636367, ..., 0.20831498, 0.16556489, 0.17426219], [0.48041207, 0.67653587, 0.15482751, ..., 0.28903249, 0.6053001 , 0.5183329 ]], [[0.4218463 , 0.79194675, 0.10673222, ..., 0.91290329, 0.07070705, 0.06533048], [0.5176482 , 0.09588648, 0.05785629, ..., 0.74445702, 0.06411436, 0.93272722], [0.65454868, 0.47404823, 0.248613 , ..., 0.7994897 , 0.00723019, 0.22863478], ..., [0.28899729, 0.47502649, 0.50189362, ..., 0.63353681, 0.2161741 , 0.52784927], [0.97530189, 0.77299334, 0.17433166, ..., 0.40414108, 0.17560515, 0.6435431 ], [0.82483345, 0.61679822, 0.07607303, ..., 0.97546307, 0.47544896, 0.42619626]], ..., [[0.76125793, 0.14994329, 0.25616675, ..., 0.3110978 , 0.42849898, 0.51534763], [0.06090383, 0.83942148, 0.7478685 , ..., 0.98281623, 0.94471768, 0.87114643], [0.07598374, 0.50202748, 0.39183348, ..., 0.90094476, 0.99754183, 0.05171618], ..., [0.03236058, 0.48672171, 0.41270351, ..., 0.57755791, 0.25238258, 0.13279508], [0.55356598, 0.44052817, 0.23030395, ..., 0.41688483, 0.78158763, 0.00691797], [0.93708838, 0.36912137, 0.47974312, ..., 0.86980419, 0.23519537, 0.36666029]], [[0.25182179, 0.2412245 , 0.73716045, ..., 0.56058811, 0.76116298, 0.91665083], [0.29752268, 0.47521625, 0.78517365, ..., 0.36275836, 0.3855582 , 0.39796252], [0.64837424, 0.93013904, 0.43013657, ..., 0.29252434, 0.43388417, 0.19213601], ..., [0.47002784, 0.37581455, 0.01503693, ..., 0.94670497, 0.45283485, 0.14255734], [0.46099224, 0.19728133, 0.29603866, ..., 0.56173338, 0.85664975, 0.36612304], [0.40500002, 0.93777081, 0.47718026, ..., 0.97022398, 0.13878345, 0.46234875]], [[0.80814915, 0.6573499 , 0.98844031, ..., 0.35506909, 0.57238133, 0.55772407], [0.82121074, 0.0472883 , 0.01022363, ..., 0.74495447, 0.56374552, 0.59001714], [0.07936603, 0.60944158, 0.69307512, ..., 0.93703034, 0.95108742, 0.89183006], ..., [0.46871086, 0.89813349, 0.58511003, ..., 0.19227471, 0.9657417 , 0.04228733], [0.25719069, 0.45796692, 0.11879618, ..., 0.46287668, 0.16131289, 0.06346754], [0.26622086, 0.58782852, 0.75059223, ..., 0.46453785, 0.84503756, 0.49136529]]], ..., [[[0.24595825, 0.22888224, 0.32182035, ..., 0.34536647, 0.98978889, 0.96610741], [0.7062261 , 0.50605927, 0.45493964, ..., 0.64911145, 0.79111973, 0.41968628], [0.49163887, 0.29374068, 0.0402035 , ..., 0.26875478, 0.77330246, 0.37328166], ..., [0.50631623, 0.62115079, 0.10694509, ..., 0.02946458, 0.08707955, 0.40161108], [0.29734261, 0.89357292, 0.81867231, ..., 0.71735253, 0.0384091 , 0.81347925], [0.37752406, 0.42067261, 0.67526309, ..., 0.98588804, 0.83283376, 0.10334616]], [[0.38017377, 0.34115321, 0.79207149, ..., 0.50812452, 0.23895081, 0.07148742], [0.88737452, 0.81807538, 0.29776161, ..., 0.78816611, 0.26063484, 0.59926283], [0.59894833, 0.34490643, 0.84441206, ..., 0.65733583, 0.12483361, 0.21027011], ..., [0.34414504, 0.28848576, 0.2288048 , ..., 0.46142893, 0.77714017, 0.71765292], [0.4979345 , 0.15034249, 0.06886383, ..., 0.40603839, 0.31999012, 0.51860521], [0.43110194, 0.9804392 , 0.31629884, ..., 0.41335285, 0.27511643, 0.51353251]], [[0.94381434, 0.76890733, 0.39127111, ..., 0.96271237, 0.86247201, 0.74303454], [0.66467098, 0.27990635, 0.64948632, ..., 0.45135881, 0.76008489, 0.83830317], [0.30603182, 0.99671208, 0.00516559, ..., 0.30149606, 0.49923433, 0.53612924], ..., [0.26534084, 0.91423631, 0.32393817, ..., 0.10847965, 0.18577915, 0.90277193], [0.63555324, 0.42885637, 0.75788464, ..., 0.2249252 , 0.16539235, 0.66437468], [0.55520222, 0.24569678, 0.63933874, ..., 0.57260447, 0.88328669, 0.99965738]], ..., [[0.23665883, 0.87474578, 0.34406039, ..., 0.95710111, 0.30528723, 0.22729112], [0.23288565, 0.17212445, 0.88350315, ..., 0.80008643, 0.17704053, 0.27061622], [0.23531215, 0.08317471, 0.45443695, ..., 0.27970061, 0.44167516, 0.83101206], ..., [0.7765777 , 0.85083857, 0.53532024, ..., 0.48658506, 0.00295892, 0.31427152], [0.10483622, 0.64055979, 0.24061858, ..., 0.49013814, 0.95157452, 0.95073222], [0.08927145, 0.298102 , 0.15864436, ..., 0.75438635, 0.94102645, 0.80363095]], [[0.79105569, 0.94463325, 0.14197781, ..., 0.84792432, 0.52585528, 0.98219631], [0.27555086, 0.73150206, 0.09568962, ..., 0.72405182, 0.12769463, 0.269872 ], [0.64108678, 0.04058459, 0.94025768, ..., 0.4009301 , 0.4053847 , 0.45263956], ..., [0.93244226, 0.31110178, 0.74869454, ..., 0.2203629 , 0.99625548, 0.3613021 ], [0.93705569, 0.12642015, 0.07272333, ..., 0.27276198, 0.02559346, 0.18888946], [0.5060677 , 0.16582334, 0.45641618, ..., 0.36966345, 0.21199553, 0.57036422]], [[0.1579501 , 0.43399463, 0.33305473, ..., 0.72062581, 0.09089408, 0.46801674], [0.80388422, 0.44565217, 0.09236271, ..., 0.45001844, 0.86898301, 0.04700004], [0.43069897, 0.52392843, 0.30365478, ..., 0.5168545 , 0.92064449, 0.21076152], ..., [0.78912088, 0.52060884, 0.44481339, ..., 0.43142158, 0.49854599, 0.94226066], [0.6591077 , 0.22995358, 0.85632786, ..., 0.0163168 , 0.67715882, 0.66533288], [0.69649484, 0.3830937 , 0.97115614, ..., 0.474954 , 0.6910759 , 0.0024426 ]]], [[[0.8812977 , 0.52990592, 0.68720081, ..., 0.25158147, 0.95300368, 0.83270155], [0.36946595, 0.86266098, 0.9981577 , ..., 0.0512539 , 0.21043011, 0.96136438], [0.92848947, 0.69601277, 0.39893447, ..., 0.76266082, 0.83318147, 0.57076049], ..., [0.59185795, 0.34317819, 0.8216833 , ..., 0.37054556, 0.32539188, 0.83138712], [0.30751771, 0.8905983 , 0.35295667, ..., 0.58109528, 0.18602127, 0.70316343], [0.94523594, 0.89266556, 0.9129278 , ..., 0.27437687, 0.85581052, 0.40736097]], [[0.61903366, 0.17768096, 0.20004045, ..., 0.24513606, 0.97649992, 0.78750456], [0.74171295, 0.06420493, 0.13078014, ..., 0.10271265, 0.92322172, 0.52549136], [0.35649358, 0.09121999, 0.59714006, ..., 0.09038648, 0.95568992, 0.88786517], ..., [0.1951419 , 0.35983635, 0.02835732, ..., 0.41805157, 0.98567836, 0.33500389], [0.5130469 , 0.10127787, 0.37657177, ..., 0.5548686 , 0.02802434, 0.09255354], [0.31892341, 0.22327591, 0.70079612, ..., 0.65177652, 0.36454187, 0.55889016]], [[0.713563 , 0.80668792, 0.62295335, ..., 0.76927945, 0.45168095, 0.47622414], [0.23534076, 0.25628903, 0.47984627, ..., 0.1118137 , 0.23848373, 0.95057044], [0.92104614, 0.35096439, 0.92303385, ..., 0.88794103, 0.62658272, 0.54415774], ..., [0.76469842, 0.69209464, 0.59651183, ..., 0.02312253, 0.93223626, 0.02998868], [0.43981093, 0.88059608, 0.23185422, ..., 0.11931282, 0.85869389, 0.72612408], [0.22805762, 0.99093292, 0.77968432, ..., 0.64448747, 0.40076654, 0.49998084]], ..., [[0.55454581, 0.72838592, 0.80078297, ..., 0.02934981, 0.36141168, 0.92235286], [0.69920372, 0.20135236, 0.60398804, ..., 0.10088171, 0.61223561, 0.56004922], [0.48370954, 0.30974685, 0.23227567, ..., 0.9993179 , 0.88545362, 0.40994422], ..., [0.48179227, 0.7560184 , 0.98983205, ..., 0.51173294, 0.87448709, 0.87830181], [0.474664 , 0.25382473, 0.67278561, ..., 0.37359185, 0.58205851, 0.87021926], [0.0307573 , 0.30201894, 0.1188687 , ..., 0.63912265, 0.80505937, 0.52530069]], [[0.45865053, 0.24568661, 0.1364253 , ..., 0.4185187 , 0.97105976, 0.50755438], [0.08320665, 0.08363109, 0.29052666, ..., 0.21522553, 0.56585147, 0.39572174], [0.83858149, 0.89156279, 0.60850865, ..., 0.51697218, 0.41662254, 0.28971969], ..., [0.32621144, 0.92949499, 0.21256 , ..., 0.43909881, 0.14457817, 0.07494238], [0.26293119, 0.72253603, 0.56961613, ..., 0.11889462, 0.65322035, 0.26283144], [0.11996778, 0.72302136, 0.34828203, ..., 0.62870438, 0.2627548 , 0.97537898]], [[0.15049742, 0.13355254, 0.13111659, ..., 0.6182433 , 0.14021961, 0.74979436], [0.85768109, 0.80170492, 0.1287862 , ..., 0.4874209 , 0.11573587, 0.79665572], [0.97456363, 0.9958738 , 0.51737308, ..., 0.54586519, 0.11681617, 0.57564705], ..., [0.9871208 , 0.00366077, 0.82439961, ..., 0.24850475, 0.6516194 , 0.83336038], [0.67526951, 0.02493922, 0.37042143, ..., 0.26017638, 0.69757959, 0.43414264], [0.19502116, 0.61535375, 0.14399157, ..., 0.95704426, 0.29952863, 0.03132993]]], [[[0.52569852, 0.55863156, 0.19171453, ..., 0.39952653, 0.8593332 , 0.7972117 ], [0.84488431, 0.00978781, 0.11138905, ..., 0.46161593, 0.33245313, 0.58292359], [0.84760011, 0.79638808, 0.83036357, ..., 0.27557937, 0.16398154, 0.82052796], ..., [0.15284241, 0.45074131, 0.36413384, ..., 0.81550507, 0.00365689, 0.69844901], [0.79434536, 0.8437786 , 0.65733533, ..., 0.76064207, 0.55185676, 0.93525672], [0.31879223, 0.70764923, 0.99112058, ..., 0.98673154, 0.2911563 , 0.91514179]], [[0.6711592 , 0.03029873, 0.41495906, ..., 0.06514305, 0.79882035, 0.98961363], [0.24292411, 0.83165407, 0.87030781, ..., 0.30685852, 0.47061046, 0.20137262], [0.61027513, 0.14649138, 0.21948951, ..., 0.07893222, 0.96914312, 0.86776997], ..., [0.92141789, 0.81828727, 0.36344585, ..., 0.55997439, 0.10175524, 0.31870258], [0.4853792 , 0.61141468, 0.98948955, ..., 0.12996432, 0.51987349, 0.31565042], [0.73790632, 0.27213087, 0.47809463, ..., 0.02944255, 0.1172691 , 0.57555885]], [[0.8695807 , 0.55011096, 0.50736083, ..., 0.1704603 , 0.37730776, 0.31854719], [0.96622385, 0.63608366, 0.83156905, ..., 0.16562476, 0.38006444, 0.41122999], [0.31477216, 0.01609947, 0.93462188, ..., 0.62333926, 0.86458163, 0.47275372], ..., [0.76267871, 0.72351569, 0.07769564, ..., 0.36738682, 0.8612665 , 0.49850223], [0.72431747, 0.07660612, 0.40935344, ..., 0.07275951, 0.6786824 , 0.0172008 ], [0.39432451, 0.21767252, 0.64698269, ..., 0.32593159, 0.81850545, 0.54994284]], ..., [[0.16498203, 0.46803033, 0.01302804, ..., 0.16151766, 0.93291864, 0.46863964], [0.40090742, 0.46572081, 0.11036432, ..., 0.3797671 , 0.37684997, 0.77426263], [0.97403272, 0.73999596, 0.90576512, ..., 0.05496293, 0.81857529, 0.20109693], ..., [0.29444647, 0.80089898, 0.7473792 , ..., 0.21047605, 0.47736508, 0.00581737], [0.44820209, 0.39771086, 0.62636386, ..., 0.77194206, 0.31737602, 0.44879254], [0.58334555, 0.96197282, 0.29588269, ..., 0.61535516, 0.76773285, 0.06282654]], [[0.95962595, 0.35366058, 0.22800554, ..., 0.30808275, 0.55139524, 0.73072175], [0.0095867 , 0.67300725, 0.44433078, ..., 0.98031982, 0.87276215, 0.05445919], [0.47260358, 0.66126687, 0.27514239, ..., 0.29998769, 0.24837054, 0.87070706], ..., [0.20988521, 0.81889369, 0.62922055, ..., 0.41551438, 0.12855102, 0.83623614], [0.67596751, 0.97609802, 0.11075943, ..., 0.2543967 , 0.61458976, 0.06617577], [0.71695736, 0.97064936, 0.21668973, ..., 0.79183775, 0.18049727, 0.23532258]], [[0.45445897, 0.90507444, 0.69830445, ..., 0.28355379, 0.58895112, 0.31490464], [0.2535872 , 0.11138536, 0.92108757, ..., 0.39429748, 0.44381946, 0.8632621 ], [0.1705587 , 0.60291787, 0.27105947, ..., 0.33130958, 0.72187736, 0.39682672], ..., [0.12361233, 0.39590528, 0.88236467, ..., 0.98163173, 0.0156829 , 0.27837289], [0.21722675, 0.53698371, 0.3993948 , ..., 0.60108177, 0.50072743, 0.67882406], [0.41995413, 0.12562182, 0.2849535 , ..., 0.0899974 , 0.12314241, 0.12477231]]]])# normalize for better sense of how good the fit is
t_target /= t_target.norm()
The target could also be an arbitrary tensor network.
Now we manually create the decomposed geometry, i.e. a ring of 4 tensors.
rank = 5
tn_guess = qtn.TensorNetwork([
qtn.Tensor(np.random.normal(size=(10, rank, rank)), inds=('a', 'left', 'up')),
qtn.Tensor(np.random.normal(size=(10, rank, rank)), inds=('b', 'up', 'right')),
qtn.Tensor(np.random.normal(size=(10, rank, rank)), inds=('c', 'right', 'bottom')),
qtn.Tensor(np.random.normal(size=(10, rank, rank)), inds=('d', 'bottom', 'left')),
])
tn_guess
TensorNetwork(tensors=4, indices=8)
Tensor(shape=(10, 5, 5), inds=[a, left, up], tags={}),
backend=numpy, dtype=float64, data=array([[[-0.78015602, -1.15018451, 0.66729699, 0.52535034, 0.99164489], [ 0.50421351, -1.41714096, -1.21008123, -1.67948961, 0.22965036], [-0.96162825, 1.07226989, -0.00686712, -0.24427729, 0.28127353], [-0.61903188, 0.55455409, -0.4206128 , 0.39144486, 1.39981349], [-1.28609482, -0.37537936, -0.06654578, -1.18791319, -0.27503377]], [[-0.69784346, 1.48865747, -1.99421972, -0.97449739, 0.95962737], [ 0.57862268, -0.40419234, 2.26892733, -0.0975704 , 0.40818307], [ 1.20090122, -1.03032058, -1.34964711, -0.39790659, -0.84666923], [-0.9702904 , 0.91515527, -0.34185375, 1.34581863, 0.33441616], [-0.81795405, -0.06521073, 0.74209116, 0.43656476, -0.54844837]], [[ 1.01879697, 1.54324406, -1.71697111, -1.99029152, 0.36787734], [-0.25939793, 0.37423177, -0.26775562, 1.8681076 , 1.89981659], [-0.47822913, 0.8137248 , -1.01041648, -0.08094205, 1.34111518], [-1.64127559, 1.99014126, -3.36082796, -0.57246946, 1.37755746], [ 0.01204368, -0.15126515, 0.82356493, -0.66697231, -1.52619257]], [[-0.28306037, -1.04792815, -0.08390491, 0.41401122, -1.78803931], [ 0.40633829, -0.11525281, 0.61520146, 0.79636047, -0.82945388], [-0.79735204, 0.78473632, -1.00449506, 1.13945531, 0.70640559], [-0.41918331, 1.9417715 , -1.30858165, -0.90018379, -0.69908655], [ 0.94660197, -0.39835077, 0.14770351, -1.25261315, -0.19566726]], [[ 0.59746951, 0.28270414, 0.00536636, -0.3486633 , -0.21310625], [-0.67619451, 0.0933047 , 0.85016033, 0.27320839, 0.61500254], [ 1.0300438 , -1.21702892, 1.48744463, 0.18376587, 0.37354031], [ 0.39129632, 1.16129727, 0.25437015, -1.05466634, -0.42191983], [-0.10678681, 0.93371773, -0.51206252, 1.42504917, -0.51698583]], [[ 1.03109434, 1.45479127, 2.24531041, 0.52807789, -0.51713315], [-0.16791074, 0.17054726, -0.02692448, -0.15309892, 0.37183074], [-1.06475606, -1.1940317 , -0.71348842, -0.77421324, -0.56130812], [-1.47993312, 0.49917507, 0.07786327, -0.57832836, 0.08536562], [ 0.94583995, 1.84873154, 0.24566128, 0.76026515, 1.09532992]], [[ 0.37852662, 0.41355723, 1.39738676, -0.87712295, 0.32997757], [ 1.46536922, 0.83771723, -1.22662868, -1.15388511, 0.88873704], [-1.14998673, 2.06589654, 1.66495575, -0.84220081, 0.17414297], [ 1.21838343, 1.22745351, -1.86230617, 0.74204522, 1.05937991], [-0.97139601, 1.09676103, -0.14747493, -1.09339567, 0.46269177]], [[-2.75484093, -0.60368313, 1.15489483, -0.36760078, -0.46787646], [-0.89739329, 1.29586377, 0.71799224, 0.63100283, 0.01726959], [ 1.23841284, 0.80721227, -1.07523926, 1.13366586, -0.87757302], [ 0.30429314, -0.29416959, 1.05129417, -0.88834844, -0.40728046], [-0.51579115, -0.24459239, 0.17525261, 1.72649764, 3.05472189]], [[-0.33909072, 0.22642345, 0.20410284, -0.27914957, 0.62339455], [-1.80044266, 0.0074221 , 0.01727558, -0.81929273, 1.34221273], [ 0.64009726, -1.28771605, -1.16089245, 1.04174771, -1.98755337], [ 2.22675208, 0.39791399, 0.12028773, -1.23010072, 0.03039808], [-0.73408099, -1.7703669 , 0.90755715, -0.6630139 , -1.63826837]], [[-0.87266589, 0.14786603, 2.67739555, 0.01876122, -0.74468492], [-0.53076711, 0.93017672, -0.73666795, 1.95328939, -1.00041395], [ 0.8849474 , 0.92792225, -0.44454441, 1.25329524, 0.91086329], [ 0.22309119, 1.04947938, 0.78134855, -0.05583536, 0.60571563], [-1.49017833, 0.43519839, 0.02601687, 0.03351543, 0.67436207]]])Tensor(shape=(10, 5, 5), inds=[b, up, right], tags={}),
backend=numpy, dtype=float64, data=array([[[ 0.46980761, 1.4752211 , -0.75945836, -1.16703036, -0.79557048], [ 1.25368713, -0.84334702, -0.47750148, -0.30460708, -0.25394566], [ 0.41221101, 0.62329518, 0.37288214, -0.35835625, 0.69089174], [ 0.39040232, 0.94771676, 0.15774743, 1.00053219, -1.00440999], [ 0.99564319, -1.40250464, 0.92224596, 0.69717599, -0.37643484]], [[-1.75454818, 1.42317486, -1.3724984 , 0.82006537, 0.17157544], [-1.25117797, -1.55277961, -0.08576705, 1.45093838, 0.44590205], [-1.66779232, -2.05645345, -1.5408473 , -1.19100262, 0.79101421], [-0.96006823, -0.70509089, -0.48789653, -1.4070474 , 1.3757334 ], [-1.3412002 , 1.43071018, -0.78611038, 1.49913405, 1.25257761]], [[ 1.01173256, -2.1821464 , 0.80042131, -0.12410179, 1.11824975], [ 0.74880376, 0.91907164, -1.53475634, -1.22519664, -0.01060341], [ 0.62169592, -1.5493997 , 0.56785608, 0.94440176, -0.48004777], [ 0.15642755, 1.16968092, -1.20270856, -0.01079324, -0.43006067], [-0.7391326 , -0.17269228, 2.14318706, -1.53759727, 0.96438507]], [[ 0.81301545, 0.21623192, -0.11587356, -0.07125904, 0.26797317], [ 0.2279286 , 0.44285815, -0.04507661, 0.80630651, -0.6696601 ], [ 2.55118397, -0.20951004, 1.39254945, -1.73444391, 0.42185336], [-0.33861622, -0.49680093, -0.27584069, 0.43160286, -1.9131848 ], [ 0.83400608, -0.6375604 , 0.73279587, -0.555061 , 0.77176996]], [[-0.29835811, -0.35028072, 0.80642 , 1.43183791, -1.52393088], [-0.90176412, -0.14754127, 0.15289375, 0.51079591, -0.66942541], [-0.09992383, 0.98712703, 1.56219707, -0.47675081, 0.97992093], [ 0.71285585, 0.49941378, 0.08737979, -2.011437 , 0.45667684], [ 3.28174229, -0.17605724, 0.32658125, -1.02232186, 1.33006677]], [[-0.54243237, -2.60588228, 0.24732004, -0.77896676, 0.15586603], [ 2.43766116, 0.89014423, 1.19208659, 0.02954385, -0.8946777 ], [ 0.29880241, 0.43255069, 0.10747108, -0.99155362, 0.44328696], [ 0.1760361 , -1.85442151, 0.06793678, -0.24868824, -1.51671546], [-0.5387599 , 1.29428523, 0.69275424, 0.26517401, 0.65710898]], [[-0.38523773, -1.82791566, 0.84767741, 0.31086344, -0.60340664], [ 0.63141943, -0.06425145, -0.87977258, 0.80770799, -0.07123915], [ 0.96230652, -0.2729407 , -0.17239175, -0.77114316, -0.60642649], [ 1.64757916, -1.83642215, 0.17275841, 0.17149691, -0.38741673], [ 2.00834557, 0.62935541, -0.07585411, -0.14848349, 2.3843525 ]], [[ 1.63459711, 0.84025491, -0.96524091, 1.78572932, -0.35729608], [ 0.64112696, -1.54776972, -1.03176327, 0.31703261, 1.00623051], [-0.83255551, -1.48393428, -0.4329668 , -0.08442599, 0.30883253], [-1.78062295, 0.16030054, -0.65885639, 1.21701173, 0.72119215], [ 0.33347822, 1.51658231, 0.52151291, -0.95327144, 0.76991206]], [[-0.31487166, -0.96041845, -0.29644553, 0.70999699, -0.53023871], [-0.78296038, 1.72031005, -1.54428401, 1.1004828 , 0.84047334], [-1.41388366, -1.37711628, 0.25808662, -0.07885528, 0.35208668], [-1.1029641 , 0.16554683, 1.18732425, -0.5754134 , 2.37576969], [-0.23284931, 0.10679985, -0.2311095 , -0.71996472, 0.34015216]], [[-1.21872791, -0.34240522, -1.64945312, -0.70726986, -1.26851267], [ 0.93908716, -1.82477743, -0.83996691, -0.29467414, 0.25095143], [-0.05463408, -0.20684235, -0.40053606, 0.09823059, -1.39885677], [-0.28324145, -0.70692315, -0.8582044 , 0.40484405, 0.48519485], [ 0.71860974, 2.45428271, -1.01833973, 0.43319917, -0.71315386]]])Tensor(shape=(10, 5, 5), inds=[c, right, bottom], tags={}),
backend=numpy, dtype=float64, data=array([[[ 1.26559976e+00, -3.24250358e+00, 1.57987147e-01, -1.91567459e-01, -1.74939704e-01], [ 9.01575673e-01, 3.48481356e-01, 3.68099415e-01, 1.46996746e-01, -1.44098060e+00], [ 2.91852243e+00, 6.64394069e-01, -1.21507728e+00, -7.68425455e-01, -1.67187745e+00], [ 1.70246638e+00, 4.39362491e-01, -8.68334331e-01, 1.33574462e+00, 1.31459808e-01], [-2.13982797e-01, 2.54212595e-01, -1.47163137e+00, -7.48247106e-02, -1.22309833e+00]], [[-9.46413541e-01, 9.48391214e-01, -3.06349197e-01, -6.94164257e-01, 7.06940632e-01], [-4.13872447e-01, 1.45002981e-01, -1.88982753e-03, 1.89031590e-01, -3.83710128e-02], [-1.42531103e+00, -9.09716540e-01, 1.07078051e+00, -7.47967039e-01, 1.61423940e+00], [ 3.76351017e-01, -1.00335602e+00, -1.78366681e+00, 1.07805850e+00, 1.50570558e+00], [-4.38467681e-02, -2.31289228e+00, -8.29678907e-01, 4.41695209e-01, 6.06392552e-01]], [[-1.84654010e-02, 5.23352113e-01, 8.25879523e-01, 9.13700560e-01, 1.49940238e+00], [-2.23494330e-01, 7.58436050e-02, 8.34791369e-01, 3.10648701e-01, -6.91366394e-01], [-5.48122181e-02, 1.32183849e+00, -1.19566619e+00, -7.25507750e-01, 5.31276139e-01], [-2.98396225e-01, -5.87467110e-02, 1.89105926e+00, 1.55441537e+00, 9.16550776e-01], [ 2.71640385e-03, -8.37437475e-01, 2.80197889e-01, 3.39226858e-02, 7.58397617e-01]], [[ 4.37153368e-01, -9.20880826e-01, -1.15086458e+00, 7.92941551e-01, -4.21540091e-01], [-1.56542735e-01, -9.77909556e-02, 8.13409734e-01, 1.83187744e-01, -1.08050323e+00], [-1.27977359e-01, 1.60752510e+00, 1.52542069e-01, -9.84154444e-01, -9.88251344e-01], [-1.10817273e-01, -3.94608390e-01, 1.29047605e+00, 1.11059646e-01, 1.54215812e-01], [ 1.00860884e-01, 1.36554948e+00, 9.70370586e-01, 3.32166893e-01, 7.74779265e-03]], [[ 2.88241591e-01, 1.27856875e+00, -1.02680304e+00, -6.29776384e-01, -1.88089440e+00], [ 2.57770062e-01, 1.26432151e+00, 3.28007331e-01, -3.99672610e-01, -1.90450202e-01], [ 9.27089728e-01, -5.43443774e-01, 3.31607583e-01, 1.58148575e-01, -1.62278078e+00], [-1.08964901e-01, 2.32122032e+00, 1.35073428e+00, 1.34849959e+00, 2.68420230e-01], [-1.39008693e+00, -2.29875173e+00, 1.09016664e+00, 1.69749033e+00, -4.00170451e-01]], [[-4.88532740e-05, -5.42180235e-02, 4.56823702e-01, 1.28544514e-01, 5.71055635e-01], [ 7.86969916e-02, -1.84876699e-01, 7.28728808e-02, -4.34287460e-01, -1.40872855e-01], [-3.14024035e-01, 4.82719428e-01, -5.03323038e-01, 3.87326712e-01, -9.33530003e-01], [-9.14134017e-01, -2.54380693e-01, -5.87269396e-01, 5.55048529e-01, -4.84109425e-01], [-6.22736263e-02, -5.27172734e-01, -2.19502828e-01, -7.24675761e-01, -6.15038014e-02]], [[-2.41822101e-01, -4.40861372e-01, 1.28020531e+00, -5.15504983e-01, -1.13181474e+00], [-9.85460882e-01, -4.20269762e-01, 3.41755007e-01, -1.49410310e+00, -5.72664529e-01], [-1.81234569e-01, 5.61220741e-01, 1.84318390e-02, -1.56658768e+00, 1.32026420e-02], [-2.72637843e-01, 2.26398711e-02, -6.83219034e-02, 9.67268325e-01, -2.00897502e+00], [-9.66864683e-01, 7.49433655e-01, -7.19944759e-01, -1.47688103e+00, -1.21995858e-01]], [[ 1.92052350e-01, -7.94067006e-01, -1.05089073e-01, 5.13967120e-01, 1.07224526e+00], [ 5.19403989e-01, 5.96135171e-01, 2.93532972e+00, -1.10531627e+00, -1.61596841e-01], [-3.68181456e-02, -1.01370583e+00, 1.33494866e+00, -7.79922127e-02, 4.31541635e-01], [ 6.67669268e-01, -1.23854796e+00, 1.19670211e+00, 8.94943953e-01, -4.52590588e-01], [-4.13639514e-01, -5.90323183e-02, -1.83400927e+00, 5.33802124e-01, -1.23491781e+00]], [[ 2.82550066e-01, 1.34019065e+00, 1.47618836e-01, 3.18935934e-01, 2.33365547e-01], [ 1.11047235e+00, 1.48954737e+00, 1.18254312e+00, 1.51889007e-01, 6.81335239e-01], [ 7.66912386e-01, -7.72599066e-01, -1.05377093e+00, -2.30445919e-01, 2.96359569e+00], [-2.62032884e-01, 2.79564373e-01, -2.45489498e-01, 1.80487614e+00, 7.18452281e-01], [-1.49681375e+00, 1.56475012e+00, -8.14211460e-01, 1.09572203e+00, -3.87112417e-01]], [[ 7.59585849e-01, -7.41412974e-01, 8.59192951e-02, -8.08984764e-01, 1.70907243e-01], [-5.02516049e-01, -6.77809391e-01, 8.63415780e-02, 8.04573195e-01, -3.20763313e-01], [ 1.07889771e+00, -1.46489337e+00, -5.25924201e-01, -1.19637976e+00, -4.50732000e-01], [-2.22109577e+00, -1.54516642e+00, -5.29300795e-02, 1.21557147e-01, -6.64953463e-01], [-1.54930294e+00, -7.83966023e-01, -9.83528887e-01, -2.57653988e+00, -2.15525733e-01]]])Tensor(shape=(10, 5, 5), inds=[d, bottom, left], tags={}),
backend=numpy, dtype=float64, data=array([[[-1.27930484, 0.56868609, -0.04511227, 0.64054414, -0.3822872 ], [ 1.96296226, -0.81014644, 1.5243949 , 0.21965852, -0.52513438], [ 0.37120528, 0.60536333, 0.05305922, 1.17225206, -0.28339594], [ 1.02704378, -0.66381247, -0.82871305, 0.19557396, 0.02410438], [-0.00433135, 1.14488283, -1.72672904, 1.1453399 , 1.44931353]], [[-0.1500713 , 0.86883734, 0.55679914, -1.23243003, 0.74866128], [ 1.09649155, 1.39563161, -0.20136257, -1.17671551, 0.05259671], [ 0.21476247, 0.60784196, -1.645901 , 0.37017771, 0.01617936], [ 0.61909615, -0.24425187, 0.90483224, -0.28921193, -1.3400998 ], [ 0.09059277, 0.915563 , 2.33863585, 0.13729618, 1.72341157]], [[-0.68490038, 0.21658118, 0.84041578, -0.35221416, 1.19137864], [ 0.16262186, 0.07495578, -0.95442251, -1.18965861, 0.20742097], [-1.70414346, -0.6219101 , 0.31503952, 0.00468846, -0.02271706], [-0.64313001, -0.49648502, 0.33405728, 2.08906955, -0.37368465], [ 0.05519131, -0.31023844, -0.7103848 , -0.30662583, 0.447459 ]], [[ 0.06097036, -1.33188636, 0.66359101, 0.06822082, -0.55111592], [ 1.13843982, 0.73800153, -0.35528282, -0.24400957, -0.39164139], [-0.30886222, 0.12777198, -0.27533939, 1.14479562, -0.00459478], [-1.27039824, 2.00243573, -0.01334696, -0.43275676, 0.18933882], [ 2.00681766, -1.94811275, 1.20560742, -0.83079527, -0.31494019]], [[-1.00452859, -2.22022371, 1.04756784, 1.31233442, 0.23278011], [-0.17029833, -1.26124317, 1.29974212, -0.74594376, 0.87760659], [ 1.23756666, 1.72474531, 0.01108487, 0.29283543, 0.83779087], [ 0.70150255, -1.49878529, 0.21028849, 0.50921937, -0.26020878], [-0.91403847, -2.19052175, 0.47391062, -1.06643603, 2.20103876]], [[ 1.47895754, 0.91587647, 1.12289351, -0.73950392, -1.03272763], [-0.4297901 , 2.31292075, 0.0894741 , -0.81900759, -0.22832817], [-0.40143942, 0.43849407, -1.95144507, -2.00634552, -1.4670846 ], [ 0.73079664, -0.52930702, 2.6423996 , 1.00496201, 1.21108303], [ 0.09139989, -2.89993774, -0.59272831, 2.05610004, -0.30087148]], [[ 0.09102333, 1.80816021, 0.73692737, -0.25995628, -1.79223806], [-0.2640261 , 1.27321227, 0.74986142, -1.28305799, 0.50824483], [-0.7876959 , 0.17267456, 0.6912336 , -0.65409602, -0.30186464], [-0.47853501, 2.24889414, -0.57309043, -0.02334962, -1.34871358], [-0.7044897 , 0.41199173, -0.70087566, 1.91994679, -0.9872519 ]], [[ 0.63347554, 1.34830758, -0.7034515 , -0.98721791, 0.38805802], [-0.10153846, 0.07715787, -0.35417287, 2.09904556, 0.54251104], [ 0.37902991, 0.34674271, -1.31287636, -0.45206177, -1.31695728], [-0.13105471, 0.45837603, 0.31327978, 1.56471624, 0.2761661 ], [ 0.81937052, -0.7020466 , 2.06208864, 0.4931506 , 0.03572492]], [[-1.28147657, -0.59339376, -0.49393403, -0.05518304, 1.42891239], [ 1.18280984, -0.01855368, -1.41566681, 0.6179491 , 1.01412767], [ 1.19664687, 0.61309825, -0.49177934, 0.99507254, -0.35187337], [-0.09692977, 0.37069061, -0.12316149, -0.27845328, 0.61482991], [ 0.30010232, -0.98145795, 0.80211381, -0.18092252, 1.23788867]], [[-2.36657269, 0.82256272, -1.63590006, -0.08677478, 0.8755201 ], [-0.03707047, 0.66825281, -0.17052149, 0.02867519, 1.55453082], [ 0.66042279, -0.5985355 , -0.37182055, 0.28266544, 0.38531637], [ 0.43409182, 0.96452319, 0.33787929, -0.68791305, -0.67517047], [-0.53953882, -0.64483842, -0.57540503, -0.22606696, 1.05878427]]])We could have any internal structure, as long as the other indices match (and the contraction is possible).
tn_guess.draw(show_inds='all', highlight_inds=['a', 'b', 'c', 'd'])
Compute the initial distance (in terms of frobeius norm):
tn_guess.distance(t_target)
2280.7571701008687
Perform the initial fitting using ALS (alternating least squares), see the
function TensorNetwork.fit
for more details:
tn_fitted = tn_guess.fit(t_target, method='als', steps=1000, progbar=True)
0.4444485069478256: 100%|██████████| 1000/1000 [00:04<00:00, 206.22it/s]
Sometimes, autodiff based optimization can do better than ALS, see
TNOptimizer
for more details:
tn_fitted.fit_(t_target, method='autodiff', steps=1000, progbar=True)
+0.444448504743 [best: +0.444448504743] : 0%| | 5/1000 [00:00<00:15, 63.55it/s]
TensorNetwork(tensors=4, indices=8)
Tensor(shape=(10, 5, 5), inds=[a, left, up], tags={}),
backend=numpy, dtype=float64, data=array([[[ 7.97929913e-05, 2.64064805e-04, -5.59014419e-04, 4.77848978e-05, -5.72201699e-05], [-8.41967276e-05, -1.37263469e-04, -1.38196127e-04, 4.15221247e-06, 6.24327449e-05], [ 3.09177390e-04, 1.14445304e-05, -9.82636773e-05, -1.44287353e-05, -8.23814600e-06], [ 1.22071721e-04, 2.36036752e-04, 1.27542429e-04, 1.64856333e-05, -7.75443191e-05], [-1.92853780e-04, -2.49784640e-04, 1.98987976e-04, 6.10701530e-05, 2.58850577e-04]], [[ 2.76478985e-04, 4.18587903e-04, -7.98353063e-04, 4.15272277e-05, -1.67725800e-04], [-8.60944545e-05, -7.86096249e-05, -3.07323134e-06, 4.66400423e-06, 7.64351009e-06], [ 4.67777760e-05, 2.47878158e-05, -5.37967645e-05, 2.19567939e-05, -1.42061286e-04], [-6.28067730e-05, 1.82857127e-05, 1.70099341e-04, -3.44295140e-06, 6.38233821e-05], [-4.29677011e-04, -3.23999430e-04, 4.08640065e-04, 6.98402869e-05, 6.34201478e-05]], [[ 2.88868435e-04, 3.31135733e-04, -7.30943567e-04, 4.62105151e-05, -2.46333422e-04], [-6.39470066e-05, -5.23097676e-05, -1.04077291e-05, 7.42614947e-06, 1.00178854e-05], [-1.11106066e-04, 1.32777845e-04, -8.71309638e-05, -1.12996344e-05, 9.93529895e-05], [-2.79302111e-05, -7.86706651e-05, 1.19413669e-04, 1.61465605e-05, -8.18387104e-07], [-5.21855068e-04, -2.76127848e-04, 3.77576936e-04, 2.46036598e-05, 1.18992649e-04]], [[ 1.68627150e-04, 2.14979450e-04, -5.47455625e-04, -4.53394200e-06, -1.45409347e-04], [-1.28022485e-05, -3.85142882e-05, -6.08611982e-05, -3.79920131e-05, -3.85377355e-05], [ 5.83303927e-05, 1.47327632e-04, -4.66989586e-05, -1.05772357e-05, 8.62340767e-07], [ 7.79574850e-06, -8.09468995e-06, 1.39755442e-05, 3.64398185e-05, 1.47020144e-05], [-3.03939089e-04, -2.46350295e-04, 2.86792818e-04, -5.20174809e-05, 8.28307665e-05]], [[-2.31873018e-04, -3.46555576e-04, 7.56116753e-04, -9.62453646e-05, 1.10198339e-04], [ 2.49170711e-04, 2.58271913e-04, -3.69993496e-04, -7.67176554e-05, -1.47022435e-04], [-2.77725419e-05, 8.15850176e-06, -8.39250502e-05, 1.19516557e-04, 3.96592449e-05], [ 2.29961491e-04, 3.24371714e-04, -5.82020652e-04, 8.49210400e-05, -9.88159508e-05], [ 3.22172715e-04, 2.40912971e-04, -2.85960938e-04, -1.00264963e-05, -1.63340432e-04]], [[ 2.92347118e-06, -4.96150578e-05, 6.32239861e-05, -2.97994525e-05, 1.47453392e-05], [ 1.05572298e-04, 6.04211262e-05, -2.41107917e-04, 1.82884531e-06, -4.85203874e-05], [ 2.77664159e-05, 4.79943544e-05, -4.75441627e-05, 1.19424000e-04, -9.27849792e-05], [ 2.15187300e-04, 1.99954317e-04, -2.18293817e-04, 1.34153721e-05, -1.24156219e-04], [ 7.56168326e-05, 1.74451127e-08, 1.19627985e-05, 9.48316863e-05, -8.33134614e-05]], [[-3.61495478e-04, -5.40581107e-04, 9.61794715e-04, 8.85659918e-05, 2.08642410e-04], [ 2.64223278e-04, 2.43432663e-04, -4.95440662e-04, 1.15794137e-05, -1.24813194e-04], [ 1.19620110e-06, 2.26573395e-05, -2.42505946e-05, -6.65330204e-05, 3.81761166e-05], [ 3.72927660e-04, 4.53883807e-04, -6.55243008e-04, 6.16445236e-05, -2.11495429e-04], [ 4.62705738e-04, 3.04942048e-04, -4.65791214e-04, 1.41454446e-04, -1.61991152e-04]], [[-2.58608932e-05, 1.39229299e-05, -1.66988908e-05, -1.39900347e-05, 2.28565504e-06], [ 6.27482282e-05, 1.30990112e-04, -2.16522771e-04, 3.74960037e-05, -1.93497884e-05], [ 8.81659843e-05, 1.12070645e-04, -4.40975471e-05, 2.56238271e-05, -1.75049190e-06], [ 1.59795187e-04, 8.70187858e-05, -2.12976632e-04, -7.97832877e-05, -7.99334671e-05], [-4.76717441e-05, 4.28090804e-05, 5.59968940e-05, -5.31800899e-06, 5.66171098e-05]], [[-7.17265387e-05, -9.73510227e-05, 5.53479186e-05, -6.92651038e-05, 7.95811822e-05], [ 6.55303309e-05, 1.29935967e-04, -2.28009338e-04, -7.60646641e-05, 2.14697924e-06], [ 6.16162850e-05, 1.60695967e-04, 1.62223502e-05, -3.35740255e-05, -6.66379555e-05], [ 1.61094162e-04, 1.27191984e-04, -2.60603937e-04, 7.39694660e-05, -1.35660189e-04], [-2.90360855e-05, 1.72196367e-05, -1.53370972e-05, -1.38419847e-04, 1.07455365e-04]], [[-2.34756539e-04, -3.56230036e-04, 4.93508449e-04, 4.22211882e-05, 1.25534804e-04], [ 1.97417569e-04, 4.54417704e-05, -4.13878398e-04, 7.31929757e-05, -1.27902486e-04], [ 2.32572409e-04, 5.07206740e-06, -3.04372796e-05, 6.87801403e-05, -1.22661761e-04], [ 2.44939382e-04, 4.43654043e-04, -3.98428579e-04, -8.07651174e-05, -1.07602236e-04], [ 3.84199345e-04, 2.85436877e-05, -2.69691769e-04, 1.72204761e-04, -1.94212650e-04]]])Tensor(shape=(10, 5, 5), inds=[b, up, right], tags={}),
backend=numpy, dtype=float64, data=array([[[ 4.77076249e-01, 1.72601801e+00, 5.02411461e-01, 1.66023308e+00, 2.05702457e+00], [-1.12103518e-01, -2.16762765e+00, -9.56305941e-01, 1.07177475e+00, -1.92797242e+00], [ 9.56206907e-01, -3.34577120e+00, 2.67210495e+00, -2.72449861e+00, 2.99943189e+00], [ 2.70434310e+00, 3.25739370e+00, 1.77471916e+00, -1.06329305e+00, -1.70622139e+00], [-4.10404757e-01, 1.64176816e+00, 3.52484424e+00, 6.61291595e-01, -2.46901381e+00]], [[-1.31828378e+00, -5.35134466e+00, 5.33778218e-01, -1.01095649e+00, -4.41737570e+00], [-1.51546728e+00, 3.85559369e+00, -9.03754346e-01, 2.24687063e+00, 1.24774112e+00], [-1.14154198e+00, -1.74936437e+00, 3.24270652e+00, -3.41093968e+00, 2.55002762e-01], [-4.25750999e-01, -2.81817371e+00, 3.69876365e-01, 1.86131897e+00, 3.78092757e+00], [ 1.27496004e+00, -4.46397454e+00, 7.39063927e-01, 8.67570256e-01, 3.25879438e+00]], [[-1.20897483e+00, -1.22603998e+00, 2.41445869e+00, 1.12124876e-01, -6.73262392e+00], [-7.42038415e-01, -2.41979748e+00, -1.76280472e+00, 7.59687061e-01, -4.42503308e-01], [ 1.09665000e-01, -4.37961878e+00, 2.91122890e+00, -3.00843685e+00, 1.31516697e+00], [-3.53254966e-01, 5.43013998e+00, 7.83586997e-01, -2.31247968e+00, -1.22625234e+00], [-1.76661982e+00, 1.98127862e-01, 3.95185436e+00, -2.01556753e+00, -9.22333100e+00]], [[-2.37818394e+00, -1.32419562e+00, 1.72393162e+00, 4.10000275e-02, -4.84970618e+00], [ 2.97555291e-02, 4.68698835e+00, -1.20738296e+00, 4.55734204e-01, 3.83596073e-02], [ 1.13189113e+00, -1.34689023e+00, 2.76791923e+00, -3.48314356e+00, 2.50451969e+00], [ 2.39742778e+00, 5.01831201e+00, -1.70268777e+00, -3.80001567e+00, 3.91482858e+00], [-5.76409892e+00, 4.16873636e+00, 4.24927802e+00, -1.58055702e+00, -8.29412172e+00]], [[ 8.93039870e-01, 7.23219283e-01, -7.39944287e-01, -1.22446086e+00, 4.94486643e-01], [-3.87893258e-01, -2.20591498e+00, 1.23368418e-01, 2.19930067e+00, -2.79746717e+00], [ 3.45903700e-01, -1.52483349e+00, 3.01552086e+00, -2.94531182e+00, 2.11518412e+00], [ 1.14694569e+00, -1.63862414e+00, -2.58570267e+00, -3.94087303e+00, 3.12413257e+00], [ 2.24696662e+00, -6.98256093e+00, 1.48368276e+00, -1.83872282e+00, -3.48647236e+00]], [[ 3.75861135e+00, -7.95535522e-01, -1.45785985e+00, 7.86729367e-01, 6.84440787e+00], [ 2.63747745e+00, 2.80003290e+00, -1.61038777e+00, 3.38112379e-01, 1.16721109e+00], [ 3.57487935e+00, -2.26548568e+00, 2.55820909e+00, -2.53533499e+00, 4.32098762e+00], [ 8.34278517e-01, 7.59953541e+00, -1.26629577e+00, -3.71793991e+00, 3.23514044e+00], [ 1.25355374e+00, 6.56751532e+00, -2.39087766e+00, -3.73329364e+00, 8.55102200e+00]], [[ 9.44321341e-01, 2.75594846e+00, -2.41398975e+00, -3.68969951e+00, 2.12400650e+00], [-3.75638151e-01, -9.58878438e+00, -1.36695030e+00, 4.47133967e+00, 1.27779431e+00], [ 8.66294030e-01, -7.58660548e+00, 2.58565955e+00, -2.23476705e+00, 2.75424094e+00], [ 1.40050112e+00, -3.73295193e+00, 2.08339711e+00, 2.47338668e+00, 6.56946266e-01], [ 2.83639036e-01, 3.60025151e+00, -2.48664120e+00, -4.28716569e+00, 5.97048378e+00]], [[ 3.07909112e-01, 5.36986571e-01, 2.17556448e+00, 1.68587389e+00, -2.31657413e+00], [-1.37723971e+00, 8.80454126e+00, -1.40695357e+00, -7.08391418e-01, -7.40197612e-02], [-4.83268330e-01, 5.83592034e-01, 3.77003222e+00, -3.61197667e+00, 1.03475496e-01], [-2.30927209e+00, -2.83069936e+00, 1.42618525e+00, -1.54577444e+00, -5.25085641e+00], [ 2.05010823e+00, 7.92841328e+00, 1.38693486e+00, -1.42840418e-01, 4.62442865e+00]], [[ 2.53928086e+00, -1.66709566e+00, -7.96981454e-03, 1.18530720e+00, 2.69473707e+00], [ 1.30923912e+00, 8.29958425e-01, -2.10395935e+00, 9.08567877e-01, 2.10778707e+00], [ 2.07816653e+00, -1.83353063e+00, 2.18934540e+00, -2.74416347e+00, 4.84912094e+00], [ 8.55163493e-01, 3.32771168e-01, -1.50422386e+00, 5.95332465e-02, 7.31087339e+00], [ 1.98292562e+00, -3.12973451e+00, 9.24335505e-01, -5.13098416e-01, 1.34741246e+00]], [[-1.39171289e+00, 2.03139897e+00, -2.78887429e+00, -3.86254174e+00, 1.07555087e+00], [ 1.94387550e-01, -7.63272096e+00, 8.95474337e-01, 4.43048540e+00, -3.06010099e+00], [ 4.38139272e-02, -6.76522904e+00, 3.72653457e+00, -2.27637939e+00, -7.38070187e-01], [-6.61069888e+00, 1.76251374e+00, 3.21391100e+00, 1.81534597e+00, -2.98149666e+00], [ 6.97587654e-02, 2.75307357e+00, -2.82534702e+00, -3.56800793e+00, 7.65257395e+00]]])Tensor(shape=(10, 5, 5), inds=[c, right, bottom], tags={}),
backend=numpy, dtype=float64, data=array([[[ 5.19878866e+00, -3.28685979e+00, 6.24807607e-01, -2.94006154e+00, 3.23552074e+00], [ 1.54051460e+00, -2.62640139e+00, -4.92930185e-01, -5.46796526e-01, 6.20536040e-01], [ 5.01153867e+00, -1.06373778e+00, -3.54673321e+00, -5.60770890e+00, -1.05108107e+00], [-8.70174141e-02, -6.71153075e+00, -4.02925035e-01, 1.79292656e+00, -6.36593421e-01], [-1.21944199e+00, -3.70518193e+00, -1.46155794e+00, -2.08825166e+00, -4.02993643e+00]], [[ 2.11909341e+00, -6.22416060e+00, -5.39642768e+00, 4.21628787e-01, 1.16926638e+00], [ 2.10819418e-01, -4.20821068e+00, -4.80077667e-03, -5.30735132e-01, 1.94300673e+00], [ 1.60740327e+01, 8.14998853e+00, -7.65389810e-02, -9.86204981e+00, -5.81696934e+00], [-2.71609524e+00, -1.09865793e+01, -1.26953267e+00, 2.87656318e+00, 7.49204313e+00], [ 4.84931237e+00, 3.78473770e+00, 4.49721937e-01, -3.56267318e+00, -3.18815968e+00]], [[-4.39374115e+00, 5.88278629e-01, 2.33293253e+00, 1.84063842e+00, -5.13670714e-01], [-1.66065649e+00, -1.74860770e+00, 3.99167777e-01, 1.93448258e-01, 1.03245756e+00], [ 1.28133429e+01, 8.66840250e+00, -4.77302264e-01, -1.04094026e+01, -8.30693019e+00], [-5.87008131e+00, -1.27912457e+01, -1.33953735e+00, 2.74559096e+00, 4.93508114e+00], [ 4.94232453e+00, 1.38809797e+00, -1.25903618e+00, -3.54718552e+00, -4.23610515e+00]], [[ 3.52307051e+00, -7.76723592e+00, -3.15378765e+00, -1.41844715e+00, 3.67380311e-02], [ 1.42089093e+00, -8.26630866e-01, 5.46743467e-01, 3.50285736e-02, 1.11617188e+00], [ 5.25282373e+00, 5.59231300e+00, 6.75432685e-02, -4.35240887e+00, 2.02438913e+00], [ 1.14973953e+00, 2.29537407e+00, 3.25110684e+00, 3.72517602e+00, 3.85391127e+00], [ 5.55369846e-01, 3.56356855e+00, 4.00641147e-01, -1.08592624e+00, -3.90450697e-02]], [[-3.83405779e-01, -6.00168644e+00, -2.75572875e+00, -2.67501121e+00, -4.31920689e+00], [-2.13892427e+00, 2.41576308e+00, 1.06448211e+00, 2.07253989e+00, -1.94862859e+00], [-8.03226786e+00, 6.13949617e+00, -2.17726450e+00, 1.40061342e+00, 2.11416710e+00], [-5.19467907e-01, 9.04024351e+00, 2.22680348e+00, 5.12479416e+00, -1.92502431e+00], [-1.06951316e+00, -1.03628014e+00, -1.15927449e+00, 2.78139309e-01, 1.42557048e+00]], [[ 5.00384040e-01, 2.27675701e+00, 3.67298543e-01, 4.55622234e-01, -3.07582837e-01], [ 2.91484444e-01, 2.28398352e+00, 1.27311126e+00, 3.75858459e-01, -3.93250522e-01], [-6.60088352e+00, -2.27785321e+00, -2.58730116e+00, -7.48101546e-01, 4.82252644e+00], [ 2.88290461e+00, 3.22742055e+00, 1.87061062e+00, 2.27251787e+00, -3.25597319e+00], [-1.71535413e+00, -6.57920906e+00, -3.12605269e+00, -1.63118529e+00, 3.10921324e-01]], [[-1.56163593e+00, 3.47562314e-01, 2.10652423e+00, 1.30318757e+00, -6.58352501e-01], [-7.13255187e-01, -8.33670807e-01, -1.84111747e-01, -1.59961092e-01, -1.66328463e-01], [ 3.41085121e+00, 4.68401799e-01, -2.29609213e+00, -6.13043267e+00, -3.68349314e+00], [-2.47597261e+00, -6.11340215e+00, 4.65267017e-01, 2.55637786e+00, 1.74101173e-01], [ 9.61346075e-01, 2.67661490e-01, -1.38712527e+00, -2.08879335e+00, -1.64358277e+00]], [[-1.32484870e+00, 8.50282770e+00, 2.73489340e+00, 4.15186210e+00, 1.54123456e+00], [ 1.79652987e+00, 2.32272154e+00, 9.90917259e-01, 3.06419238e-01, 1.78525594e-01], [-6.85981949e+00, -8.14979247e-01, -2.93432759e+00, -1.08065357e-02, 8.74356991e+00], [ 3.09679154e+00, 1.13908184e+01, 3.44050685e+00, 2.31370949e+00, -2.42509614e+00], [-4.92490120e+00, -3.39754625e+00, -2.26620475e+00, -1.45657737e+00, 4.93971026e-01]], [[-2.98315625e+00, 3.58062447e+00, 3.69723246e+00, 1.47447362e-02, -1.21625179e+00], [ 2.27400868e+00, -6.29110752e-01, 1.30425471e+00, -1.17958167e+00, 6.91572008e-01], [-3.02124467e+00, -3.97962155e+00, -1.61300706e+00, -3.48720103e+00, 4.77506548e+00], [ 2.53965205e+00, 5.03017314e+00, 4.03082652e+00, 2.21575966e+00, -1.58662708e-01], [-5.58041016e-01, 2.44898991e-01, -7.52700132e-01, 1.07308738e-01, 3.34055583e+00]], [[-8.94931943e-01, 4.59343438e+00, 3.34079111e+00, 2.99187967e-01, 1.18717299e+00], [-9.13188798e-01, 1.03039470e+00, 1.39753496e+00, 3.73721263e-01, 1.43253182e-01], [ 2.10038285e+00, 4.08334274e+00, -2.21676260e+00, -4.74300123e+00, -1.45487950e+00], [-2.21469576e+00, -1.79561908e+00, 2.30783815e-01, 3.47555915e+00, 4.33584128e-01], [-1.85957340e-01, -9.22727056e-01, -1.58507568e+00, -1.25565683e+00, -2.27592662e+00]]])Tensor(shape=(10, 5, 5), inds=[d, bottom, left], tags={}),
backend=numpy, dtype=float64, data=array([[[-3.26058191e+00, -1.05507124e+00, -1.84448208e+00, 1.97017520e+00, 6.32579050e-01], [ 2.96406288e-01, -6.85946975e-01, 5.94495651e-02, -1.72846696e-01, -1.46069457e+00], [ 6.96592733e-03, 1.57476002e+00, 9.16853925e-02, 2.62331767e+00, 2.16892078e-01], [ 1.44925472e+00, -2.27432939e+00, 1.44837730e+00, 7.65041133e-01, 1.59982624e+00], [-2.75808591e+00, 3.66149054e+00, -1.23611350e+00, -1.14266330e+00, 2.63596144e+00]], [[-2.19057924e+00, 5.63854246e+00, -9.91389914e-01, -1.28279533e+00, -2.01196212e-01], [-1.34287232e+00, -5.00000153e-01, -1.67583415e+00, -1.42669228e+00, 9.07502413e-01], [-6.03823434e-01, -7.70854344e-01, -9.20797541e-01, -2.13359935e+00, 3.49979321e-01], [-2.13376444e-02, 2.79074181e+00, 1.63593126e+00, 1.29600751e-02, -4.97877067e-01], [-3.80253241e+00, -3.25958819e+00, -7.30035078e-01, 2.52678717e+00, 2.10422589e+00]], [[-1.71436332e+00, -2.34754339e+00, -5.17788754e-01, 2.06512947e+00, 4.68431407e-01], [ 1.56324781e+00, -1.80596080e+00, 5.31077903e-01, 9.99908414e-01, 3.55170149e-01], [-2.61513111e+00, -6.41519940e-01, -2.88767359e-01, -7.20554250e-01, 2.50535720e-01], [ 5.53324964e-01, 8.51005197e-01, 8.97215134e-01, 6.54825279e-01, -2.61356647e+00], [-2.27567613e+00, 1.03618361e+00, -2.23446857e+00, -2.53077606e+00, 1.45781843e+00]], [[-1.09470567e+00, -1.72582577e-01, 1.37554226e+00, -2.91623345e+00, -6.72664779e-01], [ 2.04532083e+00, 3.21109436e-01, 1.95673242e+00, 6.13990815e-01, -5.78926258e-01], [-2.38295143e-01, 2.44691963e+00, 1.77628871e+00, 3.34464593e-02, -1.72440031e+00], [-1.07984558e+00, 1.27386583e+00, -2.46665429e-01, -1.77015410e+00, -1.71136515e+00], [ 3.54640640e+00, -1.11783976e+00, -1.17083845e+00, 9.97753666e-01, -4.87608032e-01]], [[-3.28004305e+00, 2.62208702e-01, -1.27133880e+00, -7.58361706e-01, -1.44583630e-01], [-2.90971786e-01, 3.62213188e-01, 3.57111370e-02, -4.10216264e-01, -1.18704233e+00], [ 1.36933141e+00, -1.72497200e+00, -1.13450564e+00, -1.39270925e+00, 6.14607113e-01], [ 1.09781492e-01, 1.24091209e+00, 7.16212934e-01, 1.97755830e+00, 4.82539221e-01], [-1.36193101e+00, -2.71033969e+00, -4.94491719e-01, -3.59983301e-01, 3.11415274e+00]], [[ 7.23081868e-01, -3.78294067e-01, -1.30130254e+00, 5.96159201e-01, -3.13725761e-01], [ 1.51638315e+00, -4.42754730e-01, -4.81164893e-02, -6.12446148e-01, -7.21830137e-01], [ 1.23873366e-01, -3.55372642e+00, -7.24973991e-01, -1.58576543e+00, 6.20496535e-01], [ 6.73096609e-01, 1.78457993e+00, 1.02118970e+00, 2.23949321e+00, -4.42873883e-01], [ 2.32015010e+00, -3.24977015e+00, 2.96902342e+00, -2.48641264e+00, -4.44695170e-01]], [[-1.39447484e+00, 3.76814029e+00, -7.84081110e-01, 9.90670000e-01, -8.44368581e-01], [ 2.68506451e-01, 2.92968361e-01, -2.98519110e-01, -4.48420653e-01, -8.97501394e-01], [ 2.19490223e+00, -2.71256886e+00, 2.24744634e-01, -1.75975830e+00, -3.58813552e-01], [-5.99653756e-01, 1.87826655e+00, 1.41999168e+00, 1.99158804e+00, 7.35288291e-01], [ 1.47080878e+00, 4.71296924e-02, 1.14611927e+00, 2.26431438e+00, 6.68122358e-01]], [[ 2.91658322e+00, 3.13038278e+00, 1.66022289e+00, 5.06454344e-01, -9.49291801e-01], [-2.54295498e-01, 3.55438034e-02, -9.37708273e-01, -1.47877115e+00, 4.35133994e-01], [ 4.65520454e-01, -2.88157660e+00, 1.05533731e-01, -2.44073060e-01, 1.27900323e+00], [ 5.90747359e-01, 1.27347822e+00, 1.16202397e+00, 1.61316922e+00, -3.65454520e-01], [ 2.47691998e+00, -1.69541490e+00, 1.77343467e+00, 1.19597320e+00, -2.25017655e+00]], [[ 7.67209998e-02, -1.52704023e+00, -1.01548815e+00, 3.75700975e-01, 1.18224162e+00], [ 1.01479366e+00, 9.06737944e-01, 6.39210944e-01, 4.69507143e-01, -2.71689251e-01], [ 2.13618963e-01, -6.49631640e-01, -2.99108418e-01, 1.44448607e-02, -8.51883598e-02], [ 7.10666363e-01, 5.34858948e-01, -9.95133874e-01, 1.52097454e+00, 2.73379057e-03], [-2.60251699e-02, 2.36356934e-01, 7.73711793e-01, -1.26594311e+00, -4.40907360e-01]], [[-5.68212729e+00, 4.59561703e+00, 2.20149728e-01, 3.04660694e-01, -1.68065409e+00], [ 1.32413937e+00, -6.80610107e-03, 1.58062148e+00, -1.60937205e+00, -1.68416251e+00], [ 1.07803287e+00, -3.51505553e+00, -6.44081386e-02, -1.62332928e+00, 1.10673476e-01], [-7.08609541e-01, 1.97676178e+00, 3.97562674e-01, 2.21858875e+00, -1.22663951e+00], [ 7.33413666e-01, -2.85333207e-01, -2.70218185e+00, 3.06976290e+00, 3.42018501e+00]]])Double check the new fitted tensor network is close to the target:
tn_fitted.distance(t_target)
0.4444485047431454
Considering the target as a wavefunction, our fitted network has an overlap of:
tn_fitted @ t_target.H
0.8024680879837433
Note random tensors are generally not that easy to fit, resulting in a not great fidelity.