add the test for simple_ptycho_model'

This commit is contained in:
Abraham Levitan
2019-10-07 15:44:17 -04:00
parent e71c266fe4
commit f78a39daf5
2 changed files with 21 additions and 1 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ It is recommended that you clone the repository, rather than just downloading th
Step 2: Install Dependencies
----------------------------
The dependencies for CDTools can be installed, if you are managing your environment with anaconda, by running
The dependencies for CDTools can be installed, if you are managing your environment with anaconda, by running the following command in the top level directory of the package:
.. code:: bash
+20
View File
@@ -105,3 +105,23 @@ class SimplePtycho(CDIModel):
if __name__ == '__main__':
from basic_ptycho_dataset import BasicPtychoDataset
from h5py import File
from matplotlib import pyplot as plt
filename = 'example_data/lab_ptycho_data.cxi'
with File(filename, 'r') as f:
dataset = BasicPtychoDataset.from_cxi(f)
model = SimplePtycho.from_dataset(dataset)
#model.to(device='cuda')
#dataset.get_as(device='cuda')
for i, loss in enumerate(model.Adam_optimize(100, dataset)):
model.inspect(dataset)
print(i,loss)
model.compare(dataset)
plt.show()