Skip to content
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

amps, FWHMs, means Dimensions is different #6

Open
sunmingke opened this issue Jul 31, 2023 · 1 comment
Open

amps, FWHMs, means Dimensions is different #6

sunmingke opened this issue Jul 31, 2023 · 1 comment

Comments

@sunmingke
Copy link


ValueError Traceback (most recent call last)
Cell In[3], line 24
20 train.training()
23 if name == "main":
---> 24 main()

Cell In[3], line 20, in main()
18 train.alpha2_initial = 6.
19 # 开始训练
---> 20 train.training()

File ~/.local/lib/python3.8/site-packages/gausspyplus-0.2.dev0-py3.8.egg/gausspyplus/training.py:73, in GaussPyTraining.training(self)
71 self.initialize()
72 self.getting_ready()
---> 73 self.gausspy_train_alpha()

File ~/.local/lib/python3.8/site-packages/gausspyplus-0.2.dev0-py3.8.egg/gausspyplus/training.py:90, in GaussPyTraining.gausspy_train_alpha(self)
88 g.set('phase', 'two') # Set GaussPy parameters
89 # Train AGD starting with initial guess for alpha
---> 90 g.train(alpha1_initial=self.alpha1_initial, alpha2_initial=self.alpha2_initial,
91 logger=self.logger)
92 else:
93 g.set('phase', 'one')

File ~/.local/lib/python3.8/site-packages/gausspyplus-0.2.dev0-py3.8.egg/gausspyplus/gausspy_py3/gp.py:50, in GaussianDecomposer.train(self, alpha1_initial, alpha2_initial, plot, verbose, mode, learning_rate, eps, MAD, logger)
46 return
47 print('Training...')
49 self.p['alpha1'], self.p['alpha2'], self.p['training_results'] =
---> 50 gradient_descent.train(alpha1_initial=alpha1_initial,
51 alpha2_initial=alpha2_initial,
52 training_data=self.p['training_data'],
53 phase=self.p['phase'],
54 SNR_thresh=self.p['SNR_thresh'],
55 SNR2_thresh=self.p['SNR2_thresh'],
56 plot=plot, eps=eps,
57 verbose=verbose, mode=mode,
58 learning_rate=learning_rate, MAD=MAD,
59 logger=logger)

File ~/.local/lib/python3.8/site-packages/gausspyplus-0.2.dev0-py3.8.egg/gausspyplus/gausspy_py3/gradient_descent.py:221, in train(objective_function, training_data, alpha1_initial, alpha2_initial, iterations, MAD, eps, learning_rate, p, window_size, iterations_for_convergence, plot, phase, SNR2_thresh, SNR_thresh, verbose, mode, improve_fitting_dict, logger)
219 FWHMs = training_data['fwhms']
220 amps = training_data['amplitudes']
--> 221 true_params = np.append(amps, np.append(FWHMs, means))
223 # Initialize book-keeping object
224 gd = gradient_descent(iterations)

File <array_function internals>:200, in append(*args, **kwargs)

File ~/.local/lib/python3.8/site-packages/numpy/lib/function_base.py:5493, in append(arr, values, axis)
5444 @array_function_dispatch(_append_dispatcher)
5445 def append(arr, values, axis=None):
5446 """
5447 Append values to the end of an array.
5448
(...)
5491
5492 """
-> 5493 arr = asanyarray(arr)
5494 if axis is None:
5495 if arr.ndim != 1:

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (73,) + inhomogeneous part.
my python is 3.8.10, lmfit 12.2. ,numpy 1.24.4, scipy 1.10.1

@sunmingke
Copy link
Author

There was a problem in the second step, I just gave it 432 spectrum training samples, it is not clear if it is my python package version of the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant