Last active
April 28, 2020 16:37
-
-
Save jcrist/8d1dd1ef93fcd2baab871efff615d028 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from scipy import stats as sps\n", | |
"import pymc3 as pm\n", | |
"from prefect import task, Flow\n", | |
"from prefect.engine.executors import DaskExecutor, LocalDaskExecutor" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"@task\n", | |
"def flip_coin(p):\n", | |
" return sps.bernoulli(p=p).rvs(1000, random_state=42)\n", | |
"\n", | |
"@task\n", | |
"def infer_p(samples):\n", | |
" with pm.Model() as model:\n", | |
" bias = pm.Beta('bias', 1, 1)\n", | |
" coin = pm.Bernoulli('coin', p=bias, observed=samples)\n", | |
" trace = pm.sample(tune=1500, target_accept=.9, chains=1, cores=1)\n", | |
" print(trace['bias'].mean())" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[2020-04-28 15:17:56] INFO - prefect.FlowRunner | Beginning Flow run for 'CoinFlow'\n", | |
"[2020-04-28 15:17:56] INFO - prefect.FlowRunner | Starting flow run.\n", | |
"[2020-04-28 15:17:57] INFO - prefect.TaskRunner | Task 'flip_coin': Starting task run...\n", | |
"[2020-04-28 15:17:57] INFO - prefect.TaskRunner | Task 'flip_coin': finished task run for task with final state: 'Success'\n", | |
"[2020-04-28 15:17:57] INFO - prefect.TaskRunner | Task 'infer_p': Starting task run...\n" | |
] | |
}, | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"Auto-assigning NUTS sampler...\n", | |
"Initializing NUTS using jitter+adapt_diag...\n", | |
"Sequential sampling (1 chains in 1 job)\n", | |
"NUTS: [bias]\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"\n", | |
" <div>\n", | |
" <style>\n", | |
" /* Turns off some styling */\n", | |
" progress {\n", | |
" /* gets rid of default border in Firefox and Opera. */\n", | |
" border: none;\n", | |
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n", | |
" background-size: auto;\n", | |
" }\n", | |
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n", | |
" background: #F44336;\n", | |
" }\n", | |
" </style>\n", | |
" <progress value='2500' class='' max='2500', style='width:300px; height:20px; vertical-align: middle;'></progress>\n", | |
" 100.00% [2500/2500 00:02<00:00 Sampling chain 0, 0 divergences]\n", | |
" </div>\n", | |
" " | |
], | |
"text/plain": [ | |
"<IPython.core.display.HTML object>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"Sampling 1 chain for 1_500 tune and 1_000 draw iterations (1_500 + 1_000 draws total) took 3 seconds.\n", | |
"Only one chain was sampled, this makes it impossible to run some convergence checks\n" | |
] | |
}, | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"0.4976689139171085\n", | |
"[2020-04-28 15:18:12] INFO - prefect.TaskRunner | Task 'infer_p': finished task run for task with final state: 'Success'\n", | |
"[2020-04-28 15:18:12] INFO - prefect.FlowRunner | Flow run SUCCESS: all reference tasks succeeded\n" | |
] | |
} | |
], | |
"source": [ | |
"# Single value\n", | |
"with Flow('CoinFlow') as flow:\n", | |
" flips = flip_coin(.5)\n", | |
" infer_p(flips)\n", | |
"\n", | |
" flow.run()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[2020-04-28 16:26:58] INFO - prefect.FlowRunner | Beginning Flow run for 'CoinFlow'\n", | |
"[2020-04-28 16:26:58] INFO - prefect.FlowRunner | Starting flow run.\n", | |
"[2020-04-28 16:26:58] INFO - prefect.TaskRunner | Task 'flip_coin': Starting task run...\n" | |
] | |
}, | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"/Users/twiecki/miniconda3/envs/pymc3/lib/python3.7/site-packages/distributed/node.py:244: UserWarning: Port 8787 is already in use.\n", | |
"Perhaps you already have a cluster running?\n", | |
"Hosting the HTTP server on port 59233 instead\n", | |
" http_address[\"port\"], self.http_server.port\n" | |
] | |
}, | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[2020-04-28 16:26:58] INFO - prefect.TaskRunner | Task 'flip_coin[0]': Starting task run...\n", | |
"[2020-04-28 16:26:58] INFO - prefect.TaskRunner | Task 'flip_coin[1]': Starting task run...\n", | |
"[2020-04-28 16:26:58] INFO - prefect.TaskRunner | Task 'flip_coin[0]': finished task run for task with final state: 'Success'\n", | |
"[2020-04-28 16:26:58] INFO - prefect.TaskRunner | Task 'flip_coin[1]': finished task run for task with final state: 'Success'\n", | |
"[2020-04-28 16:26:58] INFO - prefect.TaskRunner | Task 'flip_coin': finished task run for task with final state: 'Mapped'\n", | |
"[2020-04-28 16:26:58] INFO - prefect.TaskRunner | Task 'infer_p': Starting task run...\n", | |
"[2020-04-28 16:26:58] INFO - prefect.TaskRunner | Task 'infer_p[1]': Starting task run...\n", | |
"[2020-04-28 16:26:58] INFO - prefect.TaskRunner | Task 'infer_p[0]': Starting task run...\n", | |
"[2020-04-28 16:26:59] ERROR - prefect.TaskRunner | Unexpected error: ValueError('Cannot compute test value: input 0 (Elemwise{neg,no_inplace}.0) of Op Elemwise{log1p,no_inplace}(Elemwise{neg,no_inplace}.0) missing default value. \\nBacktrace when that variable is created:\\n\\n File \"<ipython-input-2-59b546126d39>\", line 8, in infer_p\\n bias = pm.Beta(\\'bias\\', 1, 1)\\n File \"/Users/twiecki/working/projects/pymc/pymc3/distributions/distribution.py\", line 66, in __new__\\n return model.Var(name, dist, data, total_size)\\n File \"/Users/twiecki/working/projects/pymc/pymc3/model.py\", line 1005, in Var\\n model=self)\\n File \"/Users/twiecki/working/projects/pymc/pymc3/model.py\", line 1743, in __init__\\n transformed_name, transform.apply(distribution), total_size=total_size)\\n File \"/Users/twiecki/working/projects/pymc/pymc3/model.py\", line 998, in Var\\n total_size=total_size, model=self)\\n File \"/Users/twiecki/working/projects/pymc/pymc3/model.py\", line 1459, in __init__\\n self.logp_nojac_unscaledt = distribution.logp_nojac(self)\\n File \"/Users/twiecki/working/projects/pymc/pymc3/distributions/transforms.py\", line 197, in logp_nojac\\n return self.dist.logp(self.transform_used.backward(x))\\n File \"/Users/twiecki/working/projects/pymc/pymc3/distributions/continuous.py\", line 1315, in logp\\n log1pval = tt.log1p(-value)\\n')\n", | |
"Traceback (most recent call last):\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3/lib/python3.7/site-packages/theano/gof/op.py\", line 625, in __call__\n", | |
" storage_map[ins] = [self._get_test_value(ins)]\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3/lib/python3.7/site-packages/theano/gof/op.py\", line 581, in _get_test_value\n", | |
" raise AttributeError('%s has no test value %s' % (v, detailed_err_msg))\n", | |
"AttributeError: Elemwise{neg,no_inplace}.0 has no test value \n", | |
"Backtrace when that variable is created:\n", | |
"\n", | |
" File \"<ipython-input-2-59b546126d39>\", line 8, in infer_p\n", | |
" bias = pm.Beta('bias', 1, 1)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/distributions/distribution.py\", line 66, in __new__\n", | |
" return model.Var(name, dist, data, total_size)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/model.py\", line 1005, in Var\n", | |
" model=self)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/model.py\", line 1743, in __init__\n", | |
" transformed_name, transform.apply(distribution), total_size=total_size)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/model.py\", line 998, in Var\n", | |
" total_size=total_size, model=self)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/model.py\", line 1459, in __init__\n", | |
" self.logp_nojac_unscaledt = distribution.logp_nojac(self)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/distributions/transforms.py\", line 197, in logp_nojac\n", | |
" return self.dist.logp(self.transform_used.backward(x))\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/distributions/continuous.py\", line 1315, in logp\n", | |
" log1pval = tt.log1p(-value)\n", | |
"\n", | |
"\n", | |
"During handling of the above exception, another exception occurred:\n", | |
"\n", | |
"Traceback (most recent call last):\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3/lib/python3.7/site-packages/prefect/engine/runner.py\", line 48, in inner\n", | |
" new_state = method(self, state, *args, **kwargs)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3/lib/python3.7/site-packages/prefect/engine/task_runner.py\", line 884, in get_task_run_state\n", | |
" self.task.run, timeout=self.task.timeout, **raw_inputs\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3/lib/python3.7/site-packages/prefect/utilities/executors.py\", line 182, in timeout_handler\n", | |
" return fn(*args, **kwargs)\n", | |
" File \"<ipython-input-2-59b546126d39>\", line 8, in infer_p\n", | |
" bias = pm.Beta('bias', 1, 1)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/distributions/distribution.py\", line 66, in __new__\n", | |
" return model.Var(name, dist, data, total_size)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/model.py\", line 1005, in Var\n", | |
" model=self)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/model.py\", line 1743, in __init__\n", | |
" transformed_name, transform.apply(distribution), total_size=total_size)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/model.py\", line 998, in Var\n", | |
" total_size=total_size, model=self)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/model.py\", line 1459, in __init__\n", | |
" self.logp_nojac_unscaledt = distribution.logp_nojac(self)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/distributions/transforms.py\", line 197, in logp_nojac\n", | |
" return self.dist.logp(self.transform_used.backward(x))\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/distributions/continuous.py\", line 1315, in logp\n", | |
" log1pval = tt.log1p(-value)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3/lib/python3.7/site-packages/theano/gof/op.py\", line 639, in __call__\n", | |
" (i, ins, node, detailed_err_msg))\n", | |
"ValueError: Cannot compute test value: input 0 (Elemwise{neg,no_inplace}.0) of Op Elemwise{log1p,no_inplace}(Elemwise{neg,no_inplace}.0) missing default value. \n", | |
"Backtrace when that variable is created:\n", | |
"\n", | |
" File \"<ipython-input-2-59b546126d39>\", line 8, in infer_p\n", | |
" bias = pm.Beta('bias', 1, 1)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/distributions/distribution.py\", line 66, in __new__\n", | |
" return model.Var(name, dist, data, total_size)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/model.py\", line 1005, in Var\n", | |
" model=self)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/model.py\", line 1743, in __init__\n", | |
" transformed_name, transform.apply(distribution), total_size=total_size)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/model.py\", line 998, in Var\n", | |
" total_size=total_size, model=self)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/model.py\", line 1459, in __init__\n", | |
" self.logp_nojac_unscaledt = distribution.logp_nojac(self)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/distributions/transforms.py\", line 197, in logp_nojac\n", | |
" return self.dist.logp(self.transform_used.backward(x))\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/distributions/continuous.py\", line 1315, in logp\n", | |
" log1pval = tt.log1p(-value)\n", | |
"\n", | |
"[2020-04-28 16:26:59] INFO - prefect.TaskRunner | Task 'infer_p[1]': finished task run for task with final state: 'Failed'\n" | |
] | |
}, | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"Auto-assigning NUTS sampler...\n", | |
"Initializing NUTS using jitter+adapt_diag...\n", | |
"Sequential sampling (1 chains in 1 job)\n", | |
"NUTS: [bias]\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"\n", | |
" <div>\n", | |
" <style>\n", | |
" /* Turns off some styling */\n", | |
" progress {\n", | |
" /* gets rid of default border in Firefox and Opera. */\n", | |
" border: none;\n", | |
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n", | |
" background-size: auto;\n", | |
" }\n", | |
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n", | |
" background: #F44336;\n", | |
" }\n", | |
" </style>\n", | |
" <progress value='2500' class='' max='2500', style='width:300px; height:20px; vertical-align: middle;'></progress>\n", | |
" 100.00% [2500/2500 00:02<00:00 Sampling chain 0, 0 divergences]\n", | |
" </div>\n", | |
" " | |
], | |
"text/plain": [ | |
"<IPython.core.display.HTML object>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"Sampling 1 chain for 1_500 tune and 1_000 draw iterations (1_500 + 1_000 draws total) took 2 seconds.\n", | |
"Only one chain was sampled, this makes it impossible to run some convergence checks\n" | |
] | |
}, | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"0.4969830636996289\n", | |
"[2020-04-28 16:27:02] INFO - prefect.TaskRunner | Task 'infer_p[0]': finished task run for task with final state: 'Success'\n", | |
"[2020-04-28 16:27:02] INFO - prefect.TaskRunner | Task 'infer_p': finished task run for task with final state: 'Mapped'\n", | |
"[2020-04-28 16:27:05] INFO - prefect.FlowRunner | Flow run FAILED: some reference tasks failed.\n" | |
] | |
} | |
], | |
"source": [ | |
"# Map over two coins\n", | |
"with Flow('CoinFlow') as flow:\n", | |
" flips = flip_coin.map([.5, .25])\n", | |
" infer_p.map(flips)\n", | |
" flow.run(executor=DaskExecutor(n_workers=4, threads_per_worker=1))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[2020-04-28 15:03:38] INFO - prefect.FlowRunner | Beginning Flow run for 'CoinFlow'\n", | |
"[2020-04-28 15:03:38] INFO - prefect.FlowRunner | Starting flow run.\n", | |
"[2020-04-28 15:03:38] INFO - prefect.TaskRunner | Task 'flip_coin': Starting task run...\n", | |
"[2020-04-28 15:03:38] INFO - prefect.TaskRunner | Task 'flip_coin[0]': Starting task run...\n", | |
"[2020-04-28 15:03:38] INFO - prefect.TaskRunner | Task 'flip_coin[1]': Starting task run...\n", | |
"[2020-04-28 15:03:38] INFO - prefect.TaskRunner | Task 'flip_coin[0]': finished task run for task with final state: 'Success'\n", | |
"[2020-04-28 15:03:38] INFO - prefect.TaskRunner | Task 'flip_coin[1]': finished task run for task with final state: 'Success'\n", | |
"[2020-04-28 15:03:38] INFO - prefect.TaskRunner | Task 'flip_coin': finished task run for task with final state: 'Mapped'\n", | |
"[2020-04-28 15:03:38] INFO - prefect.TaskRunner | Task 'infer_p': Starting task run...\n", | |
"[2020-04-28 15:03:38] INFO - prefect.TaskRunner | Task 'infer_p[0]': Starting task run...\n", | |
"[2020-04-28 15:03:38] INFO - prefect.TaskRunner | Task 'infer_p[1]': Starting task run...\n" | |
] | |
}, | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"Auto-assigning NUTS sampler...\n", | |
"Initializing NUTS using jitter+adapt_diag...\n", | |
"Auto-assigning NUTS sampler...\n", | |
"Initializing NUTS using jitter+adapt_diag...\n", | |
"Multiprocess sampling (2 chains in 2 jobs)\n", | |
"Multiprocess sampling (2 chains in 2 jobs)\n", | |
"NUTS: [bias]\n", | |
"NUTS: [bias]\n", | |
"ERROR (theano.gof.opt): Optimization failure due to: local_upcast_elemwise_constant_inputs\n", | |
"ERROR (theano.gof.opt): node: Elemwise{add,no_inplace}(TensorConstant{1.0}, Elemwise{exp,no_inplace}.0)\n", | |
"ERROR (theano.gof.opt): TRACEBACK:\n", | |
"ERROR (theano.gof.opt): Traceback (most recent call last):\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/op.py\", line 625, in __call__\n", | |
" storage_map[ins] = [self._get_test_value(ins)]\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/op.py\", line 581, in _get_test_value\n", | |
" raise AttributeError('%s has no test value %s' % (v, detailed_err_msg))\n", | |
"AttributeError: Elemwise{Cast{float64}}.0 has no test value \n", | |
"\n", | |
"During handling of the above exception, another exception occurred:\n", | |
"\n", | |
"Traceback (most recent call last):\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/opt.py\", line 2034, in process_node\n", | |
" replacements = lopt.transform(node)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/tensor/opt.py\", line 2522, in local_upcast_elemwise_constant_inputs\n", | |
" new_inputs.append(T.shape_padleft(\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/tensor/basic.py\", line 4572, in shape_padleft\n", | |
" return DimShuffle(_t.broadcastable, pattern)(_t)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/op.py\", line 637, in __call__\n", | |
" raise ValueError(\n", | |
"ValueError: Cannot compute test value: input 0 (Elemwise{Cast{float64}}.0) of Op InplaceDimShuffle{}(Elemwise{Cast{float64}}.0) missing default value. \n", | |
"\n", | |
"ERROR (theano.gof.opt): Optimization failure due to: local_upcast_elemwise_constant_inputs\n", | |
"ERROR (theano.gof.opt): node: Elemwise{add,no_inplace}(Elemwise{true_div,no_inplace}.0, TensorConstant{0.0})\n", | |
"ERROR (theano.gof.opt): TRACEBACK:\n", | |
"ERROR (theano.gof.opt): Traceback (most recent call last):\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/op.py\", line 625, in __call__\n", | |
" storage_map[ins] = [self._get_test_value(ins)]\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/op.py\", line 581, in _get_test_value\n", | |
" raise AttributeError('%s has no test value %s' % (v, detailed_err_msg))\n", | |
"AttributeError: Elemwise{Cast{float64}}.0 has no test value \n", | |
"\n", | |
"During handling of the above exception, another exception occurred:\n", | |
"\n", | |
"Traceback (most recent call last):\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/opt.py\", line 2034, in process_node\n", | |
" replacements = lopt.transform(node)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/tensor/opt.py\", line 2522, in local_upcast_elemwise_constant_inputs\n", | |
" new_inputs.append(T.shape_padleft(\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/tensor/basic.py\", line 4572, in shape_padleft\n", | |
" return DimShuffle(_t.broadcastable, pattern)(_t)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/op.py\", line 637, in __call__\n", | |
" raise ValueError(\n", | |
"ValueError: Cannot compute test value: input 0 (Elemwise{Cast{float64}}.0) of Op InplaceDimShuffle{}(Elemwise{Cast{float64}}.0) missing default value. \n", | |
"\n", | |
"<<!! BUG IN FGRAPH.REPLACE OR A LISTENER !!>> <class 'theano.gof.fg.CachedConstantError'> You manually constructed a FunctionGraph, but you passed it a graph that has a cached constant. This should not happen. Clone the graph before building the FunctionGraph. local_upcast_elemwise_constant_inputs\n", | |
"ERROR (theano.gof.opt): Optimization failure due to: local_upcast_elemwise_constant_inputs\n", | |
"ERROR (theano.gof.opt): node: Elemwise{add,no_inplace}(TensorConstant{1.0}, Elemwise{exp,no_inplace}.0)\n", | |
"ERROR (theano.gof.opt): TRACEBACK:\n", | |
"ERROR (theano.gof.opt): Traceback (most recent call last):\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/opt.py\", line 2072, in process_node\n", | |
" fgraph.replace_all_validate_remove(repl_pairs,\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/toolbox.py\", line 569, in replace_all_validate_remove\n", | |
" chk = fgraph.replace_all_validate(replacements, reason)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/toolbox.py\", line 518, in replace_all_validate\n", | |
" fgraph.replace(r, new_r, reason=reason, verbose=False)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/fg.py\", line 514, in replace\n", | |
" self.change_input(node, i, new_r, reason=reason)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/fg.py\", line 445, in change_input\n", | |
" self.__import_r__(new_r, reason=reason)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/fg.py\", line 346, in __import_r__\n", | |
" self.__import__(variable.owner, reason=reason)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/fg.py\", line 405, in __import__\n", | |
" self.__setup_r__(input)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/fg.py\", line 192, in __setup_r__\n", | |
" raise CachedConstantError(\n", | |
"theano.gof.fg.CachedConstantError: You manually constructed a FunctionGraph, but you passed it a graph that has a cached constant. This should not happen. Clone the graph before building the FunctionGraph.\n", | |
"\n", | |
"<<!! BUG IN FGRAPH.REPLACE OR A LISTENER !!>> <class 'AssertionError'> local_add_canonizer\n", | |
"ERROR (theano.gof.opt): Optimization failure due to: local_add_canonizer\n", | |
"ERROR (theano.gof.opt): node: Elemwise{add,no_inplace}(TensorConstant{1.0}, Elemwise{exp,no_inplace}.0)\n", | |
"ERROR (theano.gof.opt): TRACEBACK:\n", | |
"ERROR (theano.gof.opt): Traceback (most recent call last):\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/opt.py\", line 2072, in process_node\n", | |
" fgraph.replace_all_validate_remove(repl_pairs,\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/toolbox.py\", line 569, in replace_all_validate_remove\n", | |
" chk = fgraph.replace_all_validate(replacements, reason)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/toolbox.py\", line 518, in replace_all_validate\n", | |
" fgraph.replace(r, new_r, reason=reason, verbose=False)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/fg.py\", line 513, in replace\n", | |
" assert (node == 'output' and self.outputs[i] is r) or (node.inputs[i] is r)\n", | |
"AssertionError\n", | |
"\n" | |
] | |
}, | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[2020-04-28 15:03:42] ERROR - prefect.TaskRunner | Unexpected error: AssertionError()\n", | |
"Traceback (most recent call last):\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/prefect/engine/runner.py\", line 48, in inner\n", | |
" new_state = method(self, state, *args, **kwargs)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/prefect/engine/task_runner.py\", line 883, in get_task_run_state\n", | |
" result = timeout_handler(\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/prefect/utilities/executors.py\", line 182, in timeout_handler\n", | |
" return fn(*args, **kwargs)\n", | |
" File \"<ipython-input-4-c604f0a61750>\", line 10, in infer_p\n", | |
" trace = pm.sample(tune=1500, target_accept=.9)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/sampling.py\", line 498, in sample\n", | |
" trace = _mp_sample(**sample_args)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/sampling.py\", line 1368, in _mp_sample\n", | |
" strace = _choose_backend(None, idx, model=model)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/sampling.py\", line 1289, in _choose_backend\n", | |
" return NDArray(**kwds)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/backends/ndarray.py\", line 197, in __init__\n", | |
" super().__init__(name, model, vars, test_point)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/backends/base.py\", line 66, in __init__\n", | |
" self.fn = model.fastfn(vars)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/model.py\", line 1129, in fastfn\n", | |
" f = self.makefn(outs, mode, *args, **kwargs)\n", | |
" File \"/Users/twiecki/working/projects/pymc/pymc3/model.py\", line 1095, in makefn\n", | |
" return theano.function(self.vars, outs,\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/compile/function.py\", line 306, in function\n", | |
" fn = pfunc(params=inputs,\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/compile/pfunc.py\", line 483, in pfunc\n", | |
" return orig_function(inputs, cloned_outputs, mode,\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/compile/function_module.py\", line 1832, in orig_function\n", | |
" m = Maker(inputs,\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/compile/function_module.py\", line 1519, in __init__\n", | |
" optimizer_profile = optimizer(fgraph)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/opt.py\", line 108, in __call__\n", | |
" return self.optimize(fgraph)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/opt.py\", line 97, in optimize\n", | |
" ret = self.apply(fgraph, *args, **kwargs)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/opt.py\", line 251, in apply\n", | |
" sub_prof = optimizer.optimize(fgraph)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/opt.py\", line 97, in optimize\n", | |
" ret = self.apply(fgraph, *args, **kwargs)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/opt.py\", line 2513, in apply\n", | |
" lopt_change = self.process_node(fgraph, node, lopt)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/opt.py\", line 2082, in process_node\n", | |
" self.failure_callback(e, self, repl_pairs, lopt, node)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/opt.py\", line 1933, in warn_inplace\n", | |
" return NavigatorOptimizer.warn(exc, nav, repl_pairs, local_opt, node)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/opt.py\", line 1919, in warn\n", | |
" raise exc\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/opt.py\", line 2072, in process_node\n", | |
" fgraph.replace_all_validate_remove(repl_pairs,\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/toolbox.py\", line 569, in replace_all_validate_remove\n", | |
" chk = fgraph.replace_all_validate(replacements, reason)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/toolbox.py\", line 518, in replace_all_validate\n", | |
" fgraph.replace(r, new_r, reason=reason, verbose=False)\n", | |
" File \"/Users/twiecki/miniconda3/envs/pymc3py38/lib/python3.8/site-packages/theano/gof/fg.py\", line 513, in replace\n", | |
" assert (node == 'output' and self.outputs[i] is r) or (node.inputs[i] is r)\n", | |
"AssertionError\n", | |
"[2020-04-28 15:03:42] INFO - prefect.TaskRunner | Task 'infer_p[0]': finished task run for task with final state: 'Failed'\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"\n", | |
" <div>\n", | |
" <style>\n", | |
" /* Turns off some styling */\n", | |
" progress {\n", | |
" /* gets rid of default border in Firefox and Opera. */\n", | |
" border: none;\n", | |
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n", | |
" background-size: auto;\n", | |
" }\n", | |
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n", | |
" background: #F44336;\n", | |
" }\n", | |
" </style>\n", | |
" <progress value='5000' class='' max='5000' style='width:300px; height:20px; vertical-align: middle;'></progress>\n", | |
" 100.00% [5000/5000 00:04<00:00 Sampling 2 chains, 0 divergences]\n", | |
" </div>\n", | |
" " | |
], | |
"text/plain": [ | |
"<IPython.core.display.HTML object>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"Sampling 2 chains for 1_500 tune and 1_000 draw iterations (3_000 + 2_000 draws total) took 12 seconds.\n" | |
] | |
}, | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"0.24389610741638615\n", | |
"[2020-04-28 15:03:53] INFO - prefect.TaskRunner | Task 'infer_p[1]': finished task run for task with final state: 'Success'\n", | |
"[2020-04-28 15:03:53] INFO - prefect.TaskRunner | Task 'infer_p': finished task run for task with final state: 'Mapped'\n", | |
"[2020-04-28 15:03:55] INFO - prefect.FlowRunner | Flow run FAILED: some reference tasks failed.\n" | |
] | |
} | |
], | |
"source": [ | |
"# Map over two coins with DASK\n", | |
"with Flow('CoinFlow') as flow:\n", | |
" flips = flip_coin.map([.5, .25])\n", | |
" infer_p.map(flips)\n", | |
" flow.run(executor=DaskExecutor())" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[2020-04-28 14:13:53] INFO - prefect.FlowRunner | Beginning Flow run for 'CoinFlow'\n", | |
"[2020-04-28 14:13:53] INFO - prefect.FlowRunner | Starting flow run.\n", | |
"[2020-04-28 14:13:53] INFO - prefect.TaskRunner | Task 'flip_coin': Starting task run...\n", | |
"[2020-04-28 14:13:53] INFO - prefect.TaskRunner | Task 'flip_coin[1]': Starting task run...\n", | |
"[2020-04-28 14:13:53] INFO - prefect.TaskRunner | Task 'flip_coin[0]': Starting task run...\n", | |
"[2020-04-28 14:13:53] INFO - prefect.TaskRunner | Task 'flip_coin[1]': finished task run for task with final state: 'Success'\n", | |
"[2020-04-28 14:13:53] INFO - prefect.TaskRunner | Task 'flip_coin[0]': finished task run for task with final state: 'Success'\n", | |
"[2020-04-28 14:13:53] INFO - prefect.TaskRunner | Task 'flip_coin': finished task run for task with final state: 'Mapped'\n", | |
"[2020-04-28 14:13:53] INFO - prefect.TaskRunner | Task 'infer_p': Starting task run...\n", | |
"[2020-04-28 14:13:53] INFO - prefect.TaskRunner | Task 'infer_p[1]': Starting task run...\n", | |
"[2020-04-28 14:13:53] INFO - prefect.TaskRunner | Task 'infer_p[0]': Starting task run...\n" | |
] | |
}, | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"Auto-assigning NUTS sampler...\n", | |
"Initializing NUTS using jitter+adapt_diag...\n", | |
"Auto-assigning NUTS sampler...\n", | |
"Initializing NUTS using jitter+adapt_diag...\n", | |
"Initializing NUTS failed. Falling back to elementwise auto-assignment.\n", | |
"Multiprocess sampling (4 chains in 4 jobs)\n", | |
"NUTS: [bias]\n" | |
] | |
}, | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[2020-04-28 14:13:54] ERROR - prefect.TaskRunner | Unexpected error: ValueError('Cannot compute test value: input 2 (Elemwise{Switch}.0) of Op Elemwise{Switch}(Elemwise{eq,no_inplace}.0, InplaceDimShuffle{}.0, Elemwise{Switch}.0) missing default value. ')\n", | |
"Traceback (most recent call last):\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gof/op.py\", line 1102, in get_debug_values\n", | |
" rval.append(get_test_value(arg))\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gof/op.py\", line 1007, in get_test_value\n", | |
" return PureOp._get_test_value(v_var)\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gof/op.py\", line 581, in _get_test_value\n", | |
" raise AttributeError('%s has no test value %s' % (v, detailed_err_msg))\n", | |
"AttributeError: Elemwise{Cast{float64}}.0 has no test value \n", | |
"Backtrace when that variable is created:\n", | |
"\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in access_term_cache\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in <listcomp>\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in access_term_cache\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in <listcomp>\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1161, in access_term_cache\n", | |
" input_grads = node.op.L_op(inputs, node.outputs,\n", | |
"\n", | |
"\n", | |
"During handling of the above exception, another exception occurred:\n", | |
"\n", | |
"Traceback (most recent call last):\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/pymc3/sampling.py\", line 442, in sample\n", | |
" start_, step = init_nuts(\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/pymc3/sampling.py\", line 2007, in init_nuts\n", | |
" step = pm.NUTS(potential=potential, model=model, **kwargs)\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/pymc3/step_methods/hmc/nuts.py\", line 162, in __init__\n", | |
" super().__init__(vars, **kwargs)\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/pymc3/step_methods/hmc/base_hmc.py\", line 86, in __init__\n", | |
" super().__init__(vars, blocked=blocked, model=model, dtype=dtype, **theano_kwargs)\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/pymc3/step_methods/arraystep.py\", line 243, in __init__\n", | |
" func = model.logp_dlogp_function(\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/pymc3/model.py\", line 895, in logp_dlogp_function\n", | |
" return ValueGradFunction(self.logpt, grad_vars, extra_vars, **kwargs)\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/pymc3/model.py\", line 625, in __init__\n", | |
" grad = tt.grad(self._cost_joined, self._vars_joined)\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 604, in grad\n", | |
" rval = _populate_grad_dict(var_to_app_to_idx,\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1371, in _populate_grad_dict\n", | |
" rval = [access_grad_cache(elem) for elem in wrt]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1371, in <listcomp>\n", | |
" rval = [access_grad_cache(elem) for elem in wrt]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in access_term_cache\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in <listcomp>\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in access_term_cache\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in <listcomp>\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in access_term_cache\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in <listcomp>\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in access_term_cache\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in <listcomp>\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in access_term_cache\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in <listcomp>\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in access_term_cache\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in <listcomp>\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in access_term_cache\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in <listcomp>\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in access_term_cache\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in <listcomp>\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1151, in access_term_cache\n", | |
" for orig_output_v, new_output_grad_v in get_debug_values(\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gof/op.py\", line 1108, in get_debug_values\n", | |
" missing_test_message(\"Argument \" + str(i) +\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gof/op.py\", line 1028, in missing_test_message\n", | |
" raise AttributeError(msg)\n", | |
"AttributeError: Argument 1 has no test value\n", | |
"\n", | |
"During handling of the above exception, another exception occurred:\n", | |
"\n", | |
"Traceback (most recent call last):\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gof/op.py\", line 625, in __call__\n", | |
" storage_map[ins] = [self._get_test_value(ins)]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gof/op.py\", line 581, in _get_test_value\n", | |
" raise AttributeError('%s has no test value %s' % (v, detailed_err_msg))\n", | |
"AttributeError: Elemwise{Switch}.0 has no test value \n", | |
"\n", | |
"During handling of the above exception, another exception occurred:\n", | |
"\n", | |
"Traceback (most recent call last):\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/prefect/engine/runner.py\", line 48, in inner\n", | |
" new_state = method(self, state, *args, **kwargs)\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/prefect/engine/task_runner.py\", line 883, in get_task_run_state\n", | |
" result = timeout_handler(\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/prefect/utilities/executors.py\", line 182, in timeout_handler\n", | |
" return fn(*args, **kwargs)\n", | |
" File \"<ipython-input-2-c604f0a61750>\", line 10, in infer_p\n", | |
" trace = pm.sample(tune=1500, target_accept=.9)\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/pymc3/sampling.py\", line 457, in sample\n", | |
" step = assign_step_methods(model, step, step_kwargs=kwargs)\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/pymc3/sampling.py\", line 208, in assign_step_methods\n", | |
" return instantiate_steppers(model, steps, selected_steps, step_kwargs)\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/pymc3/sampling.py\", line 129, in instantiate_steppers\n", | |
" step = step_class(vars=vars, **args)\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/pymc3/step_methods/hmc/nuts.py\", line 162, in __init__\n", | |
" super().__init__(vars, **kwargs)\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/pymc3/step_methods/hmc/base_hmc.py\", line 86, in __init__\n", | |
" super().__init__(vars, blocked=blocked, model=model, dtype=dtype, **theano_kwargs)\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/pymc3/step_methods/arraystep.py\", line 243, in __init__\n", | |
" func = model.logp_dlogp_function(\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/pymc3/model.py\", line 895, in logp_dlogp_function\n", | |
" return ValueGradFunction(self.logpt, grad_vars, extra_vars, **kwargs)\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/pymc3/model.py\", line 625, in __init__\n", | |
" grad = tt.grad(self._cost_joined, self._vars_joined)\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 604, in grad\n", | |
" rval = _populate_grad_dict(var_to_app_to_idx,\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1371, in _populate_grad_dict\n", | |
" rval = [access_grad_cache(elem) for elem in wrt]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1371, in <listcomp>\n", | |
" rval = [access_grad_cache(elem) for elem in wrt]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in access_term_cache\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in <listcomp>\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in access_term_cache\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in <listcomp>\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in access_term_cache\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in <listcomp>\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in access_term_cache\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in <listcomp>\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in access_term_cache\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in <listcomp>\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in access_term_cache\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in <listcomp>\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in access_term_cache\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in <listcomp>\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in access_term_cache\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in <listcomp>\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in access_term_cache\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in <listcomp>\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in access_term_cache\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1021, in <listcomp>\n", | |
" output_grads = [access_grad_cache(var) for var in node.outputs]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1326, in access_grad_cache\n", | |
" term = access_term_cache(node)[idx]\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gradient.py\", line 1161, in access_term_cache\n", | |
" input_grads = node.op.L_op(inputs, node.outputs,\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/tensor/elemwise.py\", line 543, in L_op\n", | |
" rval = self._bgrad(inputs, outs, ograds)\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/tensor/elemwise.py\", line 643, in _bgrad\n", | |
" ret.append(transform(scalar_igrad))\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/tensor/elemwise.py\", line 634, in transform\n", | |
" new_r = Elemwise(node.op, {})(\n", | |
" File \"/Users/systrom/miniconda3/envs/prefect/lib/python3.8/site-packages/theano/gof/op.py\", line 637, in __call__\n", | |
" raise ValueError(\n", | |
"ValueError: Cannot compute test value: input 2 (Elemwise{Switch}.0) of Op Elemwise{Switch}(Elemwise{eq,no_inplace}.0, InplaceDimShuffle{}.0, Elemwise{Switch}.0) missing default value. \n", | |
"[2020-04-28 14:13:55] INFO - prefect.TaskRunner | Task 'infer_p[0]': finished task run for task with final state: 'Failed'\n" | |
] | |
} | |
], | |
"source": [ | |
"# Map over two coins with DASK\n", | |
"with Flow('CoinFlow') as flow:\n", | |
" flips = flip_coin.map([.5, .25])\n", | |
" infer_p.map(flips)\n", | |
" flow.run(executor=LocalDaskExecutor(scheduler='threads'))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "pymc3", | |
"language": "python", | |
"name": "pymc3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.7.6" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment