-
Notifications
You must be signed in to change notification settings - Fork 85
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
API: change CLs to be scalar #714
Comments
Quick followup: >>> import pyhf
>>> pyhf.set_backend("numpy")
>>> model = pyhf.simplemodels.hepdata_like(
... signal_data=[12.0, 11.0], bkg_data=[50.0, 52.0], bkg_uncerts=[3.0, 7.0]
>>> )
>>> observations = [51, 48]
>>> data = observations + model.config.auxdata
>>> test_poi = 1.0
>>> CLs_obs, CLs_exp_band = pyhf.infer.hypotest(
... test_poi, data, model, qtilde=True, return_expected_set=True
>>> )
>>> print(CLs_obs)
[0.05251554]
>>> type(CLs_obs)
<class 'numpy.ndarray'> but the |
We might need to consider the implications -- e.g. -- for autodiff or machine learning libs that need to use feedback? |
Maybe I'm not thinking about it clearly, but as the CLs is the end result and a scalar it won't have a gradient associated to it. @lukasheinrich @phinate can you clarify for me (my brain is currently very foggy)? |
forr backprop in particular it needs to be a scalar (we just index into it right now). The reason we had it be a (1,) vector is because (i think) pytorch didn't support pure scalars tensors. But now they all do
|
This is an easy change, but this will change all the docs and notebooks. This is prehaps minor enough that people might not care, but as I think people are mainly looking at the Or are you happy with just returning a scalar ndarray, and not a float? # numpy
>>> import numpy as np
>>> x = np.array([0.5])
>>> y = np.reshape(x, ())
>>> z = x[0]
>>> print(f"y is a {type(y)} of shape {y.shape} and has value {y}")
y is a <class 'numpy.ndarray'> of shape () and has value 0.5
>>> print(f"z is a {type(z)} of shape {z.shape} and has value {z}")
z is a <class 'numpy.float64'> of shape () and has value 0.5 # torch
>>> import torch
>>> x = torch.tensor([0.5])
>>> y = torch.reshape(x, ())
>>> z = x[0]
>>> print(f"y is a {type(y)} of shape {y.shape} and has value {y}")
y is a <class 'torch.Tensor'> of shape torch.Size([]) and has value 0.5
>>> print(f"z is a {type(z)} of shape {z.shape} and has value {z}")
z is a <class 'torch.Tensor'> of shape torch.Size([]) and has value 0.5 |
Description
right now it's returning (1,) vectors
The text was updated successfully, but these errors were encountered: