Giter Club home page Giter Club logo

Comments (3)

FelixXu35 avatar FelixXu35 commented on June 25, 2024 1

Thanks for your reply.

I agree. Nothing is really wrong.

But I believe it is worthy to add a length check, because the error message of a (<n) binary string is:

"list index out of range"

and of a (>n+1) binary string is:

"The final node after contraction has more than one remaining edge. In this case output_edge_order has to be provided."

Neither of them is clear for a beginner.

I will give a try.

from tensorcircuit.

refraction-ray avatar refraction-ray commented on June 25, 2024

BTW, why tc.about() gives me "module 'tensorcircuit' has no attribute 'about'"?

you can upgrade you tensorcircuit version: pip install -U tensorcircuit.

Thanks for report the n+1 qubit input case for c.amplitude, can be reproduced, will have a look

from tensorcircuit.

refraction-ray avatar refraction-ray commented on June 25, 2024

turns out it is a feature related to tensornetwork, when there is only one disentangling edge (one extra bit string), the contractor doesn't raise error since unspecified output edge is unique.

See code below:

for n in [2, 3, 4]:
    ns = []
    for _ in range(n):
        ns.append(tc.gates.Gate(np.array([1.0, 0.0])))
    
    ns[0][0]^ns[1][0]
    try:
        print(n, tc.contractor(ns).tensor)
    except ValueError:
        print(n, "ValueError")

The output will be:

2 1.0
3 [1. 0.]
4 ValueError

If you really want to fix it (nothing really wrong if the use specify the correct bitstring), adding a length check at the beginning of amplitude method is enough. Welcome to PR on this error check protection

from tensorcircuit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.