federicosabbadini's picture
Upload folder using huggingface_hub (part 2)
a46709e verified
Raw
History Blame Contribute Delete
21.3 kB
[NbConvertApp] Converting notebook run_clean_15model.ipynb to notebook
[NbConvertApp] ERROR | Notebook JSON is invalid: Additional properties are not allowed ('execution_count', 'outputs' were unexpected)
Failed validating 'additionalProperties' in markdown_cell:
On instance['cells'][0]:
{'cell_type': 'markdown',
'execution_count': None,
'id': 'p0c000',
'metadata': {},
'outputs': ['...0 outputs...'],
'source': '# Structural aliasing in Chronos-Bolt, Bayesian analysis\n'
'\n'
'**PATC...'}
C:\Users\feder\AppData\Local\Programs\Python\Python312\Lib\site-packages\zmq\_future.py:718: RuntimeWarning: Proactor event loop does not implement add_reader family of methods required for zmq. Registering an additional selector thread for add_reader support via tornado. Use `asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())` to avoid this warning.
self._get_loop()
[IPKernelApp] WARNING | Kernel is running over TCP without encryption. All communication (including code and outputs) is sent in plain text and is susceptible to eavesdropping. Use IPC transport or launch with kernel manager-provisioned CurveZMQ keys to enable transport encryption.
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\feder\AppData\Local\Programs\Python\Python312\Scripts\jupyter-nbconvert.EXE\__main__.py", line 7, in <module>
File "C:\Users\feder\AppData\Local\Programs\Python\Python312\Lib\site-packages\jupyter_core\application.py", line 284, in launch_instance
super().launch_instance(argv=argv, **kwargs)
File "C:\Users\feder\AppData\Local\Programs\Python\Python312\Lib\site-packages\traitlets\config\application.py", line 1080, in launch_instance
app.start()
File "C:\Users\feder\AppData\Local\Programs\Python\Python312\Lib\site-packages\nbconvert\nbconvertapp.py", line 420, in start
self.convert_notebooks()
File "C:\Users\feder\AppData\Local\Programs\Python\Python312\Lib\site-packages\nbconvert\nbconvertapp.py", line 597, in convert_notebooks
self.convert_single_notebook(notebook_filename)
File "C:\Users\feder\AppData\Local\Programs\Python\Python312\Lib\site-packages\nbconvert\nbconvertapp.py", line 563, in convert_single_notebook
output, resources = self.export_single_notebook(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\feder\AppData\Local\Programs\Python\Python312\Lib\site-packages\nbconvert\nbconvertapp.py", line 487, in export_single_notebook
output, resources = self.exporter.from_filename(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\feder\AppData\Local\Programs\Python\Python312\Lib\site-packages\nbconvert\exporters\exporter.py", line 201, in from_filename
return self.from_file(f, resources=resources, **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\feder\AppData\Local\Programs\Python\Python312\Lib\site-packages\nbconvert\exporters\exporter.py", line 220, in from_file
return self.from_notebook_node(
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\feder\AppData\Local\Programs\Python\Python312\Lib\site-packages\nbconvert\exporters\notebook.py", line 36, in from_notebook_node
nb_copy, resources = super().from_notebook_node(nb, resources, **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\feder\AppData\Local\Programs\Python\Python312\Lib\site-packages\nbconvert\exporters\exporter.py", line 154, in from_notebook_node
nb_copy, resources = self._preprocess(nb_copy, resources)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\feder\AppData\Local\Programs\Python\Python312\Lib\site-packages\nbconvert\exporters\exporter.py", line 353, in _preprocess
nbc, resc = preprocessor(nbc, resc)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\feder\AppData\Local\Programs\Python\Python312\Lib\site-packages\nbconvert\preprocessors\base.py", line 48, in __call__
return self.preprocess(nb, resources)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\feder\AppData\Local\Programs\Python\Python312\Lib\site-packages\nbconvert\preprocessors\execute.py", line 103, in preprocess
self.preprocess_cell(cell, resources, index)
File "C:\Users\feder\AppData\Local\Programs\Python\Python312\Lib\site-packages\nbconvert\preprocessors\execute.py", line 124, in preprocess_cell
cell = self.execute_cell(cell, index, store_history=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\feder\AppData\Local\Programs\Python\Python312\Lib\site-packages\jupyter_core\utils\__init__.py", line 165, in wrapped
return loop.run_until_complete(inner)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\feder\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 691, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\feder\AppData\Local\Programs\Python\Python312\Lib\site-packages\nbclient\client.py", line 1062, in async_execute_cell
await self._check_raise_for_error(cell, cell_index, exec_reply)
File "C:\Users\feder\AppData\Local\Programs\Python\Python312\Lib\site-packages\nbclient\client.py", line 918, in _check_raise_for_error
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
------------------
idata_A = cached_fit("04_A.nc", lambda: sample(model_A_contrast(live), "A"))
print("\nModel A, H1 behavioural")
rowsA = [report(idata_A, "beta_bar", label="beta_bar (log ratio)"),
report(idata_A, "beta_bar", np.exp, label="recovery ratio exp(beta_bar)"),
report(idata_A, "delta_O", label="delta_O (overlap slope, M1)"),
report(idata_A, "delta_P", label="delta_P (log patch-size slope)")]
pA_att = prob(idata_A, "beta_bar", lambda x: x < ATTENUATION_20)
pA_rope = prob(idata_A, "beta_bar", lambda x: np.abs(x) < ROPE_LOG)
pA_neg = prob(idata_A, "beta_bar", lambda x: x < 0)
print(f"\n P(at least 20% attenuation | D) = {pA_att:.3f} (prior: "
f"{prior_summary['p_attenuation20_prior']:.3f})")
print(f" P(practically no effect | D) = {pA_rope:.3f} (ROPE |beta| < log 1.1)")
print(f" P(beta_bar < 0 | D) = {pA_neg:.3f} (any attenuation at all)")
pA_mit = prob(idata_A, "delta_O", lambda x: x < 0)
print(f" P(delta_O < 0 | D) = {pA_mit:.3f} (M1: overlap reduces the deficit)")
display(az.summary(idata_A.posterior, var_names=["beta_bar", "delta_O", "delta_P", "tau", "sigma",
"sigma_harm", "sigma_bg"], ci_prob=0.95).round(3))
# M1, second half: which description of the configuration level does the data prefer?
# deliverable2.tex, Mitigation: "the overlap ratio, the absolute stride, or the patch size".
# idata_A IS the config_level="both" fit (it is the default), so it is reused rather than
# sampled a second time: on the full design that is one avoidable fit of the largest model.
fitsM1 = {"overlap + patch size": idata_A}
fitsM1.update({lbl: cached_fit(f"04_A_{lvl}.nc",
lambda l=lvl, n=lbl: sample(model_A_contrast(live, config_level=l), n))
for lvl, lbl in (("overlap", "overlap only"), ("patch", "patch size only"),
("none", "neither"))})
cmpM1 = az.compare(fitsM1)
display(cmpM1)
# plot_forest: ArviZ 1.x changed the API; draw manually
post_beta = idata_A.posterior["beta"].values.reshape(-1, idata_A.posterior.sizes["config"])
cfg_names = list(idata_A.posterior.coords["config"].values)
fig, ax = plt.subplots(figsize=(8, 3.4))
for j, name in enumerate(cfg_names):
lo, med, hi = np.quantile(post_beta[:, j], [0.025, 0.5, 0.975])
ax.plot([lo, hi], [j, j], color="steelblue", lw=2)
ax.plot(med, j, "o", color="steelblue", ms=5)
ax.axvline(0, color="k", lw=.9)
ax.axvline(ATTENUATION_20, color="crimson", ls="--", lw=1)
ax.set_yticks(range(len(cfg_names))); ax.set_yticklabels(cfg_names, fontsize=8)
ax.set_title("Model A: per-configuration phase-lock effect $\\beta_c$\n"
"(left of the dashed line = at least 20% attenuation)")
plt.tight_layout(); plt.savefig(FIG_DIR / "P4_A_forest.png", dpi=140, bbox_inches="tight"); plt.show()
------------------
----- stderr -----
NUTS[nutpie]: [beta_bar, delta_O, delta_P, tau, z_cfg, sigma_harm, z_harm, sigma_bg, z_bg, sigma]
----- stdout -----
checkpoint -> 04_A.nc
Model A, H1 behavioural
beta_bar (log ratio) median +0.0744 95% CrI [-0.7915, +0.9117]
recovery ratio exp(beta_bar) median +1.0772 95% CrI [+0.4531, +2.4887]
delta_O (overlap slope, M1) median +0.4363 95% CrI [-0.0344, +0.8047]
delta_P (log patch-size slope) median -0.5685 95% CrI [-1.1499, +0.0517]
P(at least 20% attenuation | D) = 0.189 (prior: 0.336)
P(practically no effect | D) = 0.223 (ROPE |beta| < log 1.1)
P(beta_bar < 0 | D) = 0.414 (any attenuation at all)
P(delta_O < 0 | D) = 0.036 (M1: overlap reduces the deficit)
----- stderr -----
NUTS[nutpie]: [beta_bar, delta_O, tau, z_cfg, sigma_harm, z_harm, sigma_bg, z_bg, sigma]
----- stdout -----
checkpoint -> 04_A_overlap.nc
----- stderr -----
NUTS[nutpie]: [beta_bar, delta_P, tau, z_cfg, sigma_harm, z_harm, sigma_bg, z_bg, sigma]
----- stdout -----
checkpoint -> 04_A_patch.nc
----- stderr -----
NUTS[nutpie]: [beta_bar, tau, z_cfg, sigma_harm, z_harm, sigma_bg, z_bg, sigma]
----- stdout -----
checkpoint -> 04_A_none.nc
------------------
---------------------------------------------------------------------------
MemoryError Traceback (most recent call last)
Cell In[22], line 31
 27 fitsM1.update({lbl: cached_fit(f"04_A_{lvl}.nc",
 28 lambda l=lvl, n=lbl: sample(model_A_contrast(live, config_level=l), n))
 29 for lvl, lbl in (("overlap", "overlap only"), ("patch", "patch size only"),
 30 ("none", "neither"))})
---> 31 cmpM1 = az.compare(fitsM1)
 32 display(cmpM1)
 33
 34 # plot_forest: ArviZ 1.x changed the API; draw manually
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\arviz_stats\loo\compare.py:202, in compare(compare_dict, method, var_name, reference, round_to)
 199 else:
 200 round_val = round_to
--> 202 ics_dict = _calculate_ics(compare_dict, var_name=var_name)
 203 names = list(ics_dict.keys())
 205 has_subsampling = any(
 206 getattr(elpd, "subsample_size", None) is not None for elpd in ics_dict.values()
 207 )
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\arviz_stats\loo\compare.py:632, in _calculate_ics(compare_dict, var_name)
 625 method_list = sorted(methods_used.keys())
 626 raise ValueError(
 627 f"Cannot compare models with incompatible cross-validation methods: "
 628 f"{method_list}. Only comparisons between 'loo' and 'loo_kfold' methods "
 629 f"are supported currently."
 630 )
--> 632 new_compare_dict = deepcopy(compare_dict)
 633 for name, dataset in compare_dict.items():
 634 if not isinstance(dataset, ELPDData):
File ~\AppData\Local\Programs\Python\Python312\Lib\copy.py:136, in deepcopy(x, memo, _nil)
 134 copier = _deepcopy_dispatch.get(cls)
 135 if copier is not None:
--> 136 y = copier(x, memo)
 137 else:
 138 if issubclass(cls, type):
File ~\AppData\Local\Programs\Python\Python312\Lib\copy.py:221, in _deepcopy_dict(x, memo, deepcopy)
 219 memo[id(x)] = y
 220 for key, value in x.items():
--> 221 y[deepcopy(key, memo)] = deepcopy(value, memo)
 222 return y
File ~\AppData\Local\Programs\Python\Python312\Lib\copy.py:143, in deepcopy(x, memo, _nil)
 141 copier = getattr(x, "__deepcopy__", None)
 142 if copier is not None:
--> 143 y = copier(memo)
 144 else:
 145 reductor = dispatch_table.get(cls)
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\xarray\core\treenode.py:297, in TreeNode.__deepcopy__(self, memo)
 296 def __deepcopy__(self, memo: dict[int, Any] | None = None) -> Self:
--> 297 return self._copy_subtree(inherit=True, deep=True, memo=memo)
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\xarray\core\treenode.py:282, in TreeNode._copy_subtree(self, inherit, deep, memo)
 278 new_tree = self._copy_node(inherit=inherit, deep=deep, memo=memo)
 279 for name, child in self.children.items():
 280 # TODO use `.children[name] = ...` once #9477 is implemented
 281 new_tree._set(
--> 282 name, child._copy_subtree(inherit=False, deep=deep, memo=memo)
 283 )
 284 return new_tree
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\xarray\core\treenode.py:278, in TreeNode._copy_subtree(self, inherit, deep, memo)
 274 def _copy_subtree(
 275 self, inherit: bool, deep: bool = False, memo: dict[int, Any] | None = None
 276 ) -> Self:
 277  """Copy entire subtree recursively."""
--> 278 new_tree = self._copy_node(inherit=inherit, deep=deep, memo=memo)
 279 for name, child in self.children.items():
 280 # TODO use `.children[name] = ...` once #9477 is implemented
 281 new_tree._set(
 282 name, child._copy_subtree(inherit=False, deep=deep, memo=memo)
 283 )
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\xarray\core\datatree.py:952, in DataTree._copy_node(self, inherit, deep, memo)
 950 """Copy just one node of a tree."""
 951 new_node = super()._copy_node(inherit=inherit, deep=deep, memo=memo)
--> 952 data = self._to_dataset_view(rebuild_dims=False, inherit=inherit)._copy(
 953  deep=deep, memo=memo
 954 )
 955 new_node._set_node_data(data)
 956 return new_node
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\xarray\core\dataset.py:1220, in Dataset._copy(self, deep, data, memo)
 1216 for k, v in self._variables.items():
 1217 if k in index_vars:
 1218 variables[k] = index_vars[k]
 1219 else:
-> 1220 variables[k] = v._copy(deep=deep, data=data.get(k), memo=memo)
 1221
 1222 attrs = copy.deepcopy(self._attrs, memo) if deep else copy.copy(self._attrs)
 1223 encoding = (
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\xarray\core\variable.py:959, in Variable._copy(self, deep, data, memo)
 956 ndata = indexing.MemoryCachedArray(data_old.array) # type: ignore[assignment]
 958 if deep:
--> 959 ndata = copy.deepcopy(ndata, memo)
 961 else:
 962 ndata = as_compatible_data(data)
File ~\AppData\Local\Programs\Python\Python312\Lib\copy.py:143, in deepcopy(x, memo, _nil)
 141 copier = getattr(x, "__deepcopy__", None)
 142 if copier is not None:
--> 143 y = copier(memo)
 144 else:
 145 reductor = dispatch_table.get(cls)
MemoryError: Unable to allocate 8.12 GiB for an array with shape (4, 2000, 136148) and data type float64