Cannot load a SolverResults object with bad status: error - python

Does anyone know what this error message means?
I tried looking in old conversations, but they had used different solvers so it seems like I need to use another method.
I run an optimization problem with pyomo in python with the solver gurobi.
My full error message:
File "C:\Users\frida.spyder-py3\26 january\optimization.py", line 183, in
solver.solve(m, tee=True)
File "C:\Users\frida\anaconda3\lib\site-packages\pyomo\solvers\plugins\solvers\direct_solver.py", line 183, in solve
default_variable_value=self._default_variable_value)
File "C:\Users\frida\anaconda3\lib\site-packages\pyomo\core\base\PyomoModel.py", line 226, in load_from
% str(results.solver.status))
ValueError: Cannot load a SolverResults object with bad status: error

ValueError: Cannot load a SolverResults object with bad status: error. This means that it is not possible to access the solution.
Your problem is either infeasible or unbounded, or a solution does not exist.
According to pyomo documentation, you can see the output of your solver with the option tee=True to the solver
SolverFactory('glpk').solve(model, tee=True)
Also you can use pprintto see your model or variables
model.pprint()
model.x.pprint()

Related

Baron solver error for solving MINLP in Pyomo

I am using Baron solver with a licence version under AMPL licence for solving a MINLP in Pyomo and Spyder.
I use baron in my code as following:
opt=SolverFactory('baron', executable='/home/LocalUser/ampl_linux-intel64/baron')
result=opt.solve(instance, keepfiles=True,tee=True)
but when I run my code, I got this error:
Solver log file: '/tmp/tmpil8__em2.baron.log'
Solver solution file: '/tmp/tmpvphbmoa8.baron.soln'
Solver problem files: ('/tmp/tmpl7sk5uym.pyomo.bar',)
/home/LocalUser/ampl_linux-intel64/baron: can't open /tmp/tmpl7sk5uym.pyomo.bar.nl
ERROR: Solver (baron) returned non-zero return code (1)
ERROR: See the solver log above for diagnostic information.
Traceback (most recent call last):
File "Platform-nonlinear.py", line 236, in <module>
result=opt.solve(instance, keepfiles=True,tee=True)
File "/home/LocalUser/.local/lib/python3.6/site-packages/pyomo/opt/base/solvers.py", line 596, in solve
"Solver (%s) did not exit normally" % self.name)
pyutilib.common._exceptions.ApplicationError: Solver (baron) did not exit normally
I tried it in both windows and linux but I got the same error at both time!!!
T really don't know how I can fix it!
What I can suggest you is that to try to relocate your temp dir to a location where you have full access to it.
Commonly, and in my case "macos", restricts access to TMPDIR only to system so probably your files can't be stored on that location and then can't be retrieved.
"printenv |grep TMP" or "echo $TMPDIR" will show you your TEMP folder\'s address
If that is the case you can find how to change the TMPDIR of your OS by a simple search.

Bayesian Logistic Regression Using Tensorflow Probability

I am having issues trying to run the Bayesian logistic regression example on tensorflow probability, as shown An introduction to probabilistic programming, now available in TensorFlow Probability.
If I just run the code on the site I get the following error:
Traceback (most recent call last):
File "<input>", line 75, in <module>
TypeError: make_simple_step_size_update_policy() missing 1 required positional argument: 'num_adaptation_steps'
Then when I specify the num_adaptation_steps=5 I get the following error:
FailedPreconditionError (see above for traceback): Error while reading resource variable step_size_hmc from Container: localhost. This could mean that the variable was uninitialized. Not found: Container localhost does not exist. (Could not find resource: localhost/step_size_hmc)
[[node mcmc_sample_chain/transformed_kernel_bootstrap_results/Identity_2/ReadVariableOp (defined at /home/abeer/PycharmProjects/TensorFlowProbability/venv/lib/python3.6/site-packages/tensorflow_probability/python/mcmc/hmc.py:127) ]]
I don't know what I am doing wrong and any help would be greatly appreciated. Thanks!!
The Challenger code in the current Colab for chapter 2 should work:
https://colab.sandbox.google.com/github/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/blob/master/Chapter2_MorePyMC/Ch2_MorePyMC_TFP.ipynb#scrollTo=oHU-MbPxs8iL
hmc=tfp.mcmc.TransformedTransitionKernel(
inner_kernel=tfp.mcmc.HamiltonianMonteCarlo(
target_log_prob_fn=unnormalized_posterior_log_prob,
num_leapfrog_steps=40,
step_size=step_size,
step_size_update_fn=tfp.mcmc.make_simple_step_size_update_policy(
num_adaptation_steps=int(burnin * 0.8)),
state_gradients_are_stopped=True),
bijector=unconstraining_bijectors)
I just noticed that the earlier HMC examples in that Chapter are lacking the num_adaptation_steps, so I'll do a PR soon to fix that. Or feel free to do so as well.
Thanks
mike

How to solve this kind of error while frozen_graph.py

How i can solve this kind of error while frozen_graph.py. i passed the parameter for getting frozen file from checkpoint. But while executing it show me
AssertionError: Openpose/concat_stage7 is not in graph
this type of error.

Azure ML Studio: How to change input value with Python before it goes through data process

I am currently attempting to change the value of input as it goes through data process in Azure ML. However, I cannot find a clue about how to access to the input data with python.
For example, if you were to use python, you can access to the column of data with
print(dataframe1["Hello World"])
I tried to change the name of Web Service Input and tried to do it like how I did for other dataframe (e.g. sample)
print(dataframe["sample"])
But it returns an error with no luck, and from what I read from an error, it's not compatible to dataframe:
object of type 'NoneType' has no len()
I tried to look up a solution with Nonetype error, but there is no good solution.
The whole error message:
requestId = 1f0f621f1d8841baa7862d5c05154942 errorComponent=Module. taskStatusCode=400. {"Exception":{"ErrorId":"FailedToEvaluateScript","ErrorCode":"0085","ExceptionType":"ModuleException","Message":"Error 0085: The following error occurred during script evaluation, please view the output log for more information:\r\n---------- Start of error message from Python interpreter ----------\r\nCaught exception while executing function: Traceback (most recent call last):\r\n File \"C:\\server\\invokepy.py\", line 211, in batch\r\n xdrutils.XDRUtils.DataFrameToRFile(outlist[i], outfiles[i], True)\r\n File \"C:\\server\\XDRReader\\xdrutils.py\", line 51, in DataFrameToRFile\r\n attributes = XDRBridge.DataFrameToRObject(dataframe)\r\n File \"C:\\server\\XDRReader\\xdrbridge.py\", line 40, in DataFrameToRObject\r\n if (len(dataframe) == 1 and type(dataframe[0]) is pd.DataFrame):\r\nTypeError: object of type 'NoneType' has no len()\r\nProcess returned with non-zero exit code 1\r\n\r\n---------- End of error message from Python interpreter ----------"}}Error: Error 0085: The following error occurred during script evaluation, please view the output log for more information:---------- Start of error message from Python interpreter ----------Caught exception while executing function: Traceback (most recent call last): File "C:\server\invokepy.py", line 211, in batch xdrutils.XDRUtils.DataFrameToRFile(outlist[i], outfiles[i], True) File "C:\server\XDRReader\xdrutils.py", line 51, in DataFrameToRFile attributes = XDRBridge.DataFrameToRObject(dataframe) File "C:\server\XDRReader\xdrbridge.py", line 40, in DataFrameToRObject if (len(dataframe) == 1 and type(dataframe[0]) is pd.DataFrame):TypeError: object of type 'NoneType' has no len()Process returned with non-zero exit code 1---------- End of error message from Python interpreter ---------- Process exited with error code -2
I have also tried to a way to pass python script in data, but it is not able to make any change to Web Service Input value as I want it to be.
I have tried to look on forums like msdn or SO, but it's been difficult to find any information about it. Please let me know if you need any more information if needed. I would greatly appreciate your help!
tl;dr; You need to also link the dataset you used for training to the same port you link the Web service input, so that the Execute Python Script has something to work on - see the image below for how this should look.
You need to keep in mind that the Predictive experiment has some conventions that need to be followed (or learned the hard way :) ). One of them is that in order to use the Web service input, you need to pair it with an actual dataset, which Azure ML Studio can then use to infer structure and to provide you with some data while testing your predictive experiment. You can see it as some sort of 'ghost' module that doesn't do anything by itself.
Hope this helps.

Error with to_proto(caffe-master/python/caffe/net_spec.py)-- 'LayerParameter' object has no attribute 'num_output'

I'm trying to create the train.protxt of resnet with pycaffe and I got this error:
File "/data/hjy1312/Downloads/caffe-master/python/caffe/net_spec.py", line 140, in _to_proto
inp._to_proto(layers, names, autonames)
File "/data/hjy1312/Downloads/caffe-master/python/caffe/net_spec.py", line 97, in _to_proto
return self.fn._to_proto(layers, names, autonames)
File "/data/hjy1312/Downloads/caffe-master/python/caffe/net_spec.py", line 162, in _to_proto
assign_proto(layer, k, v)
File "/data/hjy1312/Downloads/caffe-master/python/caffe/net_spec.py", line 64, in assign_proto
is_repeated_field = hasattr(getattr(proto, name), 'extend')
AttributeError: 'LayerParameter' object has no attribute 'num_output'
after setting the breakpoint and running my code,i found the wrong with my code is this line:
from caffe import layers as L, params as P, to_proto
return to_proto(acc, loss)
But I don't know what’s wrong with to_proto,could anyone help me?
Thank you very much!
As you noted, you get the error when executing to_protot() function, but the error is not in the function itself, but rather in the inputs you provide.
Look at the error message you got
AttributeError: 'LayerParameter' object has no attribute 'num_output'
As one can understand from the error message, the net spec you provided has a layer (maybe more than one) that has num_output attribute for the layer itself (instead of an attribute to the layer's parameters).
In order to fix this error you need to inspect the code defining the layers and see that num_output is assigned to the layer params and not to the layer directly.

Categories

Resources