Giter VIP home page Giter VIP logo

Comments (5)

zhyma avatar zhyma commented on July 22, 2024

one walk around is to replace that line by:
if not isinstance(s_prev,list): s_prev = np.zeros_like(self.state.s)
and the following line:
if not isinstance(h_prev,list): h_prev = np.zeros_like(self.state.h)

This also happens to my Spyder 3.1.2 with Python 2.7.13 64bit.

from lstm.

tldrafael avatar tldrafael commented on July 22, 2024

this change gets to work to me, @zhyma , thanks.

but i'd like to know how not isinstance(s_prev, list) is equal to s_prev == None ?

because, i'm debugging the code here, and the expected class to s_prev is numpy.ndarray, so both values, this array and None will be evaluate as False in isinstance(s_prev, list)

from lstm.

zhyma avatar zhyma commented on July 22, 2024

@tldrafael You are correct. I just got it wrong. With "if not isinstance(s_prev,list)", it runs into resetting s_prev as a zeros_like matrix everytime. Although it is running, the 'H' cell and the 'C' cell are not working properly. Thanks for pointing that out!

from lstm.

tldrafael avatar tldrafael commented on July 22, 2024

The problem seems that you can't compare an array to a single None. To solve that i compare the class of the object to Nonetype if s_prev.__class__ == 'NoneType', but after this the script raises another error ValueError: shapes (100,150) and (51,) not aligned: 150 (dim 1) != 51 (dim 0). I'm struggling here.

from lstm.

zhyma avatar zhyma commented on July 22, 2024

I think using "==" to compare different types is an out-of-date method. I remember it was running correctly on my other machine with an old version of Python but not the up-to-date one. Haven't checked the Python manual yet.

from lstm.

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.