# 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[0], un_con[1], un[0], un[1]]

edges[0] = net.connect(iso_l[0], iso_l_con[0])
edges[1] = net.connect(iso_r[1], iso_r_con[1])
edges[2] = net.connect(iso_l[2], rho[0])
edges[3] = net.connect(iso_l_con[2], rho[2])
edges[4] = net.connect(iso_r[2], rho[1])
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)[1],
op_shp[2],
message="Operator dimensions do not match MPS physical dimensions.")
tf.assert_equal(
tf.shape(A2)[1],
op_shp[3],
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.

Apache-2.0