Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Floating point error if optimized code used #689

Open
fcr opened this issue Jul 29, 2018 · 4 comments
Open

Floating point error if optimized code used #689

fcr opened this issue Jul 29, 2018 · 4 comments

Comments

@fcr
Copy link

fcr commented Jul 29, 2018

Run GCAL_Tutorial.ipynb after building the optimized code.
During the stage of "Rebuilding snapshot 'lissom_oo_or_10000.typ' " generally get:

FloatingPointError Traceback (most recent call last)
in ()
9 model_dir = param.resolve_path('examples' if model=='GCAL' else 'models', path_to_file=False)
10 runscript(os.path.join(model_dir, basename + ".ty")) # Load the model
---> 11 topo.sim.views = c(times=times)
12 save_snapshot(snapshot_name)
13

/Users/fred/Development/topographica/external/featuremapper/featuremapper/collector.pyc in call(self, attrtree, times, strict)
541 try:
542 for i, t in enumerate(np.diff(times)):
--> 543 interval_hook(float(t))
544
545 # An empty attrtree buffer stops analysis repeatedly

/Users/fred/Development/topographica/external/holoviews/holoviews/ipython/widgets.pyc in call(self, value)
203 remaining = value - completed
204 if remaining != 0:
--> 205 self.run_hook(remaining)
206 super(RunProgress, self).call(100)
207

/Users/fred/Development/topographica/topo/base/simulation.pyc in run(self, duration, until)
1345 event = self.events.pop(0)
1346 self.debug("Delivering %s",event)
-> 1347 event(self)
1348 did_event=True
1349

/Users/fred/Development/topographica/topo/base/simulation.pyc in call(self, sim)
446
447 def call(self,sim):
--> 448 self.conn.dest.input_event(self.conn,self.data)
449
450 def repr(self):

/Users/fred/Development/topographica/topo/sheet/init.pyc in input_event(self, conn, data)
314 proj.activity *= 0.0
315 self.mask.reset()
--> 316 super(SettlingCFSheet,self).input_event(conn,data)
317
318

/Users/fred/Development/topographica/topo/base/projection.pyc in input_event(self, conn, data)
467 """
468 self.verbose("Received input from %s on dest_port %s via connection %s.", conn.src.name,conn.dest_port,conn.name)
--> 469 self.present_input(data,conn)
470 self.new_input = True
471

/Users/fred/Development/topographica/topo/base/projection.pyc in present_input(self, input_activity, conn)
596 is called.
597 """
--> 598 conn.activate(input_activity)
599
600

/Users/fred/Development/topographica/topo/base/cf.pyc in activate(self, input_activity)
811 iaf(input_activity)
812 self.input_buffer = input_activity
--> 813 self.activity *=0.0
814 self.response_fn(CFIter(self), input_activity, self.activity, self.strength)
815 for of in self.output_fns:

FloatingPointError: invalid value encountered in multiply

Note that this does not occur if the non optimized code is used (but the process takes forever).

@philippjfr
Copy link
Member

Presumably the optimized code is the weave version of the code? Maybe you could try to switch to the cythonized version in that case. You can see those being added here:

projection.CFProjection.response_fn=optimized.CFPRF_DotProduct_cython()

@fcr
Copy link
Author

fcr commented Aug 5, 2018

AFAIK I am using the Cython code:

python setup.py build_ext
In file included from /Users/fred/anaconda/envs/python2/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1818:0,
from /Users/fred/anaconda/envs/python2/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:18,
from /Users/fred/anaconda/envs/python2/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from topo/optimized/optimized.c:567:
/Users/fred/anaconda/envs/python2/lib/python2.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it by "
^~~~~~~
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++

@fcr
Copy link
Author

fcr commented Aug 5, 2018

Correction.
Okay, seems that weave was active.
I just remembered that I installed weave when I was first trying to run topographica a few weeks ago, after I ran the LISSOM tutorial and I got this message:
"Caution: Unable to import Weave. Will use non-optimized versions of most components.
Note: Inline-optimized components are currently disabled; see topo.misc.inlinec".

This was in spite of building with Cython as you saw in my previous message. This is my first time encountering weave.

When I uninstall weave I get back the "Unable to import Weave" message again.

Now that you showed how to activate the cython code in the model I'll give it a try.

@fcr
Copy link
Author

fcr commented Aug 5, 2018

Ran with the Cython code. Got the same error:
`FloatingPointError Traceback (most recent call last)
in ()
11 print(model_path)
12 runscript(model_path) # Load the model
---> 13 topo.sim.views = c(times=times)
14 save_snapshot(snapshot_name)
15

/Users/fred/Development/topographica/external/featuremapper/featuremapper/collector.pyc in call(self, attrtree, times, strict)
541 try:
542 for i, t in enumerate(np.diff(times)):
--> 543 interval_hook(float(t))
544
545 # An empty attrtree buffer stops analysis repeatedly

/Users/fred/Development/topographica/external/holoviews/holoviews/ipython/widgets.pyc in call(self, value)
203 remaining = value - completed
204 if remaining != 0:
--> 205 self.run_hook(remaining)
206 super(RunProgress, self).call(100)
207

/Users/fred/Development/topographica/topo/base/simulation.pyc in run(self, duration, until)
1345 event = self.events.pop(0)
1346 self.debug("Delivering %s",event)
-> 1347 event(self)
1348 did_event=True
1349

/Users/fred/Development/topographica/topo/base/simulation.pyc in call(self, sim)
446
447 def call(self,sim):
--> 448 self.conn.dest.input_event(self.conn,self.data)
449
450 def repr(self):

/Users/fred/Development/topographica/topo/sheet/init.pyc in input_event(self, conn, data)
314 proj.activity *= 0.0
315 self.mask.reset()
--> 316 super(SettlingCFSheet,self).input_event(conn,data)
317
318

/Users/fred/Development/topographica/topo/base/projection.pyc in input_event(self, conn, data)
467 """
468 self.verbose("Received input from %s on dest_port %s via connection %s.", conn.src.name,conn.dest_port,conn.name)
--> 469 self.present_input(data,conn)
470 self.new_input = True
471

/Users/fred/Development/topographica/topo/base/projection.pyc in present_input(self, input_activity, conn)
596 is called.
597 """
--> 598 conn.activate(input_activity)
599
600

/Users/fred/Development/topographica/topo/base/cf.pyc in activate(self, input_activity)
811 iaf(input_activity)
812 self.input_buffer = input_activity
--> 813 self.activity *=0.0
814 self.response_fn(CFIter(self), input_activity, self.activity, self.strength)
815 for of in self.output_fns:

FloatingPointError: invalid value encountered in multiply`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants