# How to use the tensornetwork.TensorNetwork function in tensornetwork

## To help you get started, we’ve selected a few tensornetwork examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately. google / TensorNetwork / experiments / MERA / binary_mera_lib.py View on Github def get_env_isometry_5(hamiltonian, reduced_density, isometry, unitary):

net = tn.TensorNetwork("tensorflow")

un_r_con = net.add_node(tf.conj(unitary)) google / TensorNetwork / experiments / MERA / misc_mera.py View on Github def scalar_product(bottom, top):
"""
calculate the Hilbert-schmidt inner product between bottom and top'
Args:
bottom (tf.Tensor)
top (tf.Tensor)
Returns:
tf.Tensor:  the inner product
"""

net = tn.TensorNetwork("tensorflow")
edges = [net.connect(b[n], t[n]) for n in range(len(bottom.shape))]
out = net.contract_between(b, t)
return out.get_tensor() google / TensorNetwork / experiments / MERA / binary_mera_lib.py View on Github def two_site_descending_super_operator(rho, isometry, unitary):
"""
binary mera two-site descending super operator
Args:
rho (tf.Tensor):      hamiltonian
isometry (tf.Tensor): isometry of the binary mera
unitary  (tf.Tensor): disentanlger of the mera
Returns:
tf.Tensor
"""

net = tn.TensorNetwork("tensorflow")

out_order = [un_con, un_con, un, un]

edges = net.connect(iso_l, iso_l_con)
edges = net.connect(iso_r, iso_r_con)
edges = net.connect(iso_l, rho)
edges = net.connect(iso_l_con, rho)
edges = net.connect(iso_r, rho) google / TensorNetwork / experiments / MERA / binary_mera_lib.py View on Github def right_ascending_super_operator(hamiltonian, isometry, unitary):
"""
binary mera right ascending super operator
Args:
hamiltonian (tf.Tensor): hamiltonian
isometry (tf.Tensor): isometry of the binary mera
unitary  (tf.Tensor): disentanlger of the mera
Returns:
tf.Tensor
"""

net = tn.TensorNetwork("tensorflow")

un_r_con = net.add_node(tf.conj(unitary)) google / TensorNetwork / experiments / MERA / binary_mera_lib.py View on Github def right_descending_super_operator(reduced_density, isometry, unitary):
"""
binary mera right descending super operator
Args:
reduced_density (tf.Tensor): reduced density matrix
isometry (tf.Tensor): isometry of the binary mera
unitary  (tf.Tensor): disentanlger of the mera
Returns:
tf.Tensor
"""

net = tn.TensorNetwork("tensorflow")

un_r_con = net.add_node(tf.conj(unitary)) google / TensorNetwork / experiments / MPS / misc_mps.py View on Github """Applies a two-site local operator to an MPS.
Takes two MPS site tensors and returns new ones, with a center matrix.
"""
if tf.executing_eagerly():
# FIXME: Not ideal, but these ops are very costly at compile time
op_shp = tf.shape(op)
tf.assert_equal(
tf.shape(A1),
op_shp,
message="Operator dimensions do not match MPS physical dimensions.")
tf.assert_equal(
tf.shape(A2),
op_shp,
message="Operator dimensions do not match MPS physical dimensions.")

net = tn.TensorNetwork("tensorflow")
nA1 = net.add_node(A1, axis_names=["L", "p", "R"])
nA2 = net.add_node(A2, axis_names=["L", "p", "R"])
nop = net.add_node(op, axis_names=["p_out_1", "p_out_2", "p_in_1", "p_in_2"])

net.connect(nA1["R"], nA2["L"])
net.connect(nA1["p"], nop["p_in_1"])
net.connect(nA2["p"], nop["p_in_2"])

output_order = [nA1["L"], nop["p_out_1"], nop["p_out_2"], nA2["R"]]

nA12 = net.contract_between(nA1, nA2)
n_block = net.contract_between(nop, nA12)

nA1_new, nC, nA2_new, s_rest = net.split_node_full_svd(
n_block,
output_order[:2], google / TensorNetwork / experiments / MERA / binary_mera_lib.py View on Github def left_descending_super_operator(reduced_density, isometry, unitary):
"""
binary mera left descending super operator
Args:
reduced_density (tf.Tensor): reduced density matrix
isometry (tf.Tensor): isometry of the binary mera
unitary  (tf.Tensor): disentanlger of the mera
Returns:
tf.Tensor
"""

net = tn.TensorNetwork("tensorflow")

un_r_con = net.add_node(tf.conj(unitary)) google / TensorNetwork / experiments / MERA / binary_mera_lib.py View on Github def left_ascending_super_operator(hamiltonian, isometry, unitary):
"""
binary mera left ascending super operator
Args:
hamiltonian (tf.Tensor): hamiltonian
isometry (tf.Tensor): isometry of the binary mera
unitary  (tf.Tensor): disentanlger of the mera
Returns:
tf.Tensor
"""

net = tn.TensorNetwork("tensorflow")

un_r_con = net.add_node(tf.conj(unitary))`

## tensornetwork

A high level tensor network API for accelerated tensor network calculations. GitHub Apache-2.0 Latest version published 2 years ago

57 / 100