Closed JustinS6626 closed 3 years ago
That looks like it would work but the simplest way is just to create tensors with indices matching the ones the MERA already has.
%config InlineBackend.figure_formats = ['svg']
import quimb.tensor as qtn
mera = qtn.MERA.rand_invar(16)
mera.draw(show_inds=True, highlight_inds=mera.site_inds)
The MERA class is a subclass of TensorNetwork1D so it has a standard way to name its physical indices.
If you create tensors with those indices and add them into the same tensor network, they are implicitly connected:
inputs = [
qtn.rand_tensor(shape=[2], inds=[mera.site_ind(i)], tags='INPUT')
for i in range(mera.L)
]
tn = qtn.TensorNetwork([mera] + inputs)
tn.draw(color='INPUT')
Note the the way that quimb
works - defining the geometry simply by index names - means that while outer index names are always preserved, inner ones might get mangled.
Thank you very much! That helps a lot!
You're welcome! I should note that as mentioned here - #69 - the MERA support is rather basic at the moment. E.g. all the ingredients are there for e.g. autodiff optimization of a L=2**N
length MERA with a local hamiltonian, but no high-level functionality.
I am doing an experiment right now in which I want to input ket states into the open indices of a MERA network to use as the initial state of the system the I am simulating. Right now that way that I am doing that is the same as in this toy example:
import quimb.tensor as qtn
import quimb as qu
import quimb.gen as qg
structure = qtn.tensor_mera.MERA.rand_invar(2)
bottom = structure.select(("_UNI", "_LAYER0"))
ket_1 = qg.rand.rand_ket(2)
ket_2 = qg.rand.rand_ket(2)
ketTensor1 = qtn.Tensor(ket_1, inds=("v_1", "h_1"), tags=("_KET", "K1"))
ketTensor2 = qtn.Tensor(ket_2, inds=("v_2", "h_2"), tags=("_KET", "K2"))
qtn.tensor_core.connect(ketTensor1, bottom[0], 0, 0)
qtn.tensor_core.connect(ketTensor2, bottom[0], 0, 1)
I was wondering if this would be the correct approach, or if I should connect the ket vectors to the MERA in a different way.