Probabilistic-Programming-and-Bayesian-Methods-for-Hackers icon indicating copy to clipboard operation
Probabilistic-Programming-and-Bayesian-Methods-for-Hackers copied to clipboard

Chap 1, Section: Introducing our first hammer: PyMC3, example error, PyMC3,

Open lrlgogo opened this issue 4 years ago • 2 comments

PyMC3, python 3.84, win10, Jupyter-lab code from Chap1 Sec: Introducing our first hammer: PyMC3,

import pymc3 as pm import theano.tensor as tt

with pm.Model() as model: alpha = 1.0/count_data.mean() # Recall count_data is the # variable that holds our txt counts lambda_1 = pm.Exponential("lambda_1", alpha) lambda_2 = pm.Exponential("lambda_2", alpha)

tau = pm.DiscreteUniform("tau", lower=0, upper=n_count_data - 1)

Error:


Exception Traceback (most recent call last) in 5 alpha = 1.0/count_data.mean() # Recall count_data is the 6 # variable that holds our txt counts ----> 7 lambda_1 = pm.Exponential("lambda_1", alpha) 8 lambda_2 = pm.Exponential("lambda_2", alpha) 9

d:\python\python384r1\lib\site-packages\pymc3\distributions\distribution.py in new(cls, name, *args, **kwargs) 119 dist = cls.dist(*args, **kwargs, shape=shape) 120 else: --> 121 dist = cls.dist(*args, **kwargs) 122 return model.Var(name, dist, data, total_size, dims=dims) 123

d:\python\python384r1\lib\site-packages\pymc3\distributions\distribution.py in dist(cls, *args, **kwargs) 128 def dist(cls, *args, **kwargs): 129 dist = object.new(cls) --> 130 dist.init(*args, **kwargs) 131 return dist 132

d:\python\python384r1\lib\site-packages\pymc3\distributions\continuous.py in init(self, lam, *args, **kwargs) 1485 super().init(*args, **kwargs) 1486 self.lam = lam = tt.as_tensor_variable(floatX(lam)) -> 1487 self.mean = 1.0 / self.lam 1488 self.median = self.mean * tt.log(2) 1489 self.mode = tt.zeros_like(self.lam)

d:\python\python384r1\lib\site-packages\theano\tensor\var.py in rtruediv(self, other) 174 175 def rtruediv(self, other): --> 176 return theano.tensor.basic.true_div(other, self) 177 178 def rfloordiv(self, other):

d:\python\python384r1\lib\site-packages\theano\graph\op.py in call(self, *inputs, **kwargs) 251 252 if config.compute_test_value != "off": --> 253 compute_test_value(node) 254 255 if self.default_output is not None:

d:\python\python384r1\lib\site-packages\theano\graph\op.py in compute_test_value(node) 124 125 # Create a thunk that performs the computation --> 126 thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=[]) 127 thunk.inputs = [storage_map[v] for v in node.inputs] 128 thunk.outputs = [storage_map[v] for v in node.outputs]

d:\python\python384r1\lib\site-packages\theano\graph\op.py in make_thunk(self, node, storage_map, compute_map, no_recycling, impl) 632 ) 633 try: --> 634 return self.make_c_thunk(node, storage_map, compute_map, no_recycling) 635 except (NotImplementedError, MethodNotDefined): 636 # We requested the c code, so don't catch the error.

d:\python\python384r1\lib\site-packages\theano\graph\op.py in make_c_thunk(self, node, storage_map, compute_map, no_recycling) 598 print(f"Disabling C code for {self} due to unsupported float16") 599 raise NotImplementedError("float16") --> 600 outputs = cl.make_thunk( 601 input_storage=node_input_storage, output_storage=node_output_storage 602 )

d:\python\python384r1\lib\site-packages\theano\link\c\basic.py in make_thunk(self, input_storage, output_storage, storage_map) 1201 """ 1202 init_tasks, tasks = self.get_init_tasks() -> 1203 cthunk, module, in_storage, out_storage, error_storage = self.compile( 1204 input_storage, output_storage, storage_map 1205 )

d:\python\python384r1\lib\site-packages\theano\link\c\basic.py in compile(self, input_storage, output_storage, storage_map) 1136 input_storage = tuple(input_storage) 1137 output_storage = tuple(output_storage) -> 1138 thunk, module = self.cthunk_factory( 1139 error_storage, 1140 input_storage,

d:\python\python384r1\lib\site-packages\theano\link\c\basic.py in cthunk_factory(self, error_storage, in_storage, out_storage, storage_map) 1632 for node in self.node_order: 1633 node.op.prepare_node(node, storage_map, None, "c") -> 1634 module = get_module_cache().module_from_key(key=key, lnk=self) 1635 1636 vars = self.inputs + self.outputs + self.orphans

d:\python\python384r1\lib\site-packages\theano\link\c\cmodule.py in module_from_key(self, key, lnk) 1189 try: 1190 location = dlimport_workdir(self.dirname) -> 1191 module = lnk.compile_cmodule(location) 1192 name = module.file 1193 assert name.startswith(location)

d:\python\python384r1\lib\site-packages\theano\link\c\basic.py in compile_cmodule(self, location) 1541 try: 1542 _logger.debug(f"LOCATION {location}") -> 1543 module = c_compiler.compile_str( 1544 module_name=mod.code_hash, 1545 src_code=src_code,

d:\python\python384r1\lib\site-packages\theano\link\c\cmodule.py in compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols) 2544 # difficult to read. 2545 compile_stderr = compile_stderr.replace("\n", ". ") -> 2546 raise Exception( 2547 f"Compilation failed (return status={status}): {compile_stderr}" 2548 )

Exception: ('Compilation failed (return status=1): d:\python\python384r1\libs/python38.lib: error adding symbols: File in wrong format\r. collect2.exe: error: ld returned 1 exit status\r. ', 'FunctionGraph(Elemwise{true_div,no_inplace}(TensorConstant{1.0}, TensorConstant{0.05065023956194388}))')

lrlgogo avatar Mar 28 '21 11:03 lrlgogo

I have solved this problem, shared here for someone who need. Solution: https://github.com/pymc-devs/pymc3/wiki/Installation-Guide-(Windows), install as here in windows.

lrlgogo avatar Mar 29 '21 00:03 lrlgogo

I have solved this problem, shared here for someone who need. Solution: https://github.com/pymc-devs/pymc3/wiki/Installation-Guide-(Windows), install as here in windows.

what if Mac?

Still have same problem

ivurs avatar Aug 25 '21 02:08 ivurs