Tensorflow: feed_dict key as Tensor error with threading - python

I am running a django server and just realised I am facing a problem when I start a daemon thread and load my weights.
Has anyone faced the same problem and how you managed to solve it?
I used to solve this problem with clear_session method from Keras but now it seems that it doesn't work.
Exception in thread Thread-7:
Traceback (most recent call last):
File "/Users/ale/.virtualenvs/LoceyeCloud/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1064, in _run
allow_operation=False)
File "/Users/ale/.virtualenvs/LoceyeCloud/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3035, in as_graph_element
return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
File "/Users/ale/.virtualenvs/LoceyeCloud/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3114, in _as_graph_element_locked
raise ValueError("Tensor %s is not an element of this graph." % obj)
ValueError: Tensor Tensor("Placeholder:0", shape=(3, 3, 1, 64), dtype=float32) is not an element of this graph.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/Users/ale/platform/Server/server_back/server_backend.py", line 196, in execute
eyetracker = LoceyeEyetracker(self.screen_dimensions)
File "/Users/ale/platform/Server/server_back/LoceyeEyetracker.py", line 24, in __init__
self.iris_detector = IrisDetectorCnn(weights_filename, blink_filename)
File "/Users/ale/platform/Server/server_back/IrisDetectorCnn.py", line 17, in __init__
self.model = load_model(model_filename)
File "/Users/ale/.virtualenvs/LoceyeCloud/lib/python3.6/site-packages/keras/models.py", line 246, in load_model
topology.load_weights_from_hdf5_group(f['model_weights'], model.layers)
File "/Users/ale/.virtualenvs/LoceyeCloud/lib/python3.6/site-packages/keras/engine/topology.py", line 3166, in load_weights_from_hdf5_group
K.batch_set_value(weight_value_tuples)
File "/Users/ale/.virtualenvs/LoceyeCloud/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 2370, in batch_set_value
get_session().run(assign_ops, feed_dict=feed_dict)
File "/Users/ale/.virtualenvs/LoceyeCloud/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 889, in run
run_metadata_ptr)
File "/Users/ale/.virtualenvs/LoceyeCloud/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1067, in _run
+ e.args[0])
TypeError: Cannot interpret feed_dict key as Tensor: Tensor Tensor("Placeholder:0", shape=(3, 3, 1, 64), dtype=float32) is not an element of this graph.
and my code for loading initialising the object and loading the weights
def startPredict(self):
async = threading.Thread(target=self.execute)
async.setDaemon(False)
async.start()
def execute(self):
clear_session()
eyetracker = LoceyeEyetracker(self.screen_dimensions)
And my class is the following one.
class LoceyeEyetracker:
def __init__(self, screen_size,
weights_filename=CNN_MODEL_FILENAME,
blink_filename=CNN_BLINK_MODEL_FILENAME,
reference_filename=CNN_REFERENCE_MODEL_FILENAME):
self.iris_detector = IrisDetectorCnn(weights_filename, blink_filename)
self.screen_mapper = ScreenCoordinateMapper(screen_size)
self.reference_detector = ReferencePointDetector(reference_filename)
self.last_reference = PointPair(left=Point(x=0,y=0),right=Point(x=0,y=0))

Related

MMDetection SSD Training Error: ValueError: need at least one array to concatenate

Error message
Traceback (most recent call last):
File "tools/train.py", line 244, in <module>
main()
File "tools/train.py", line 233, in main
train_detector(
File "/home/christ/dev/repos/railsight/mmdetection-2.25.3/mmdet/apis/train.py", line 244, in train_detector
runner.run(data_loaders, cfg.workflow)
File "/home/christ/miniconda3/envs/mmdetection/lib/python3.8/site-packages/mmcv/runner/epoch_based_runner.py", line 130, in run
epoch_runner(data_loaders[i], **kwargs)
File "/home/christ/miniconda3/envs/mmdetection/lib/python3.8/site-packages/mmcv/runner/epoch_based_runner.py", line 47, in train
for i, data_batch in enumerate(self.data_loader):
File "/home/christ/miniconda3/envs/mmdetection/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 368, in __iter__
return self._get_iterator()
File "/home/christ/miniconda3/envs/mmdetection/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 314, in _get_iterator
return _MultiProcessingDataLoaderIter(self)
File "/home/christ/miniconda3/envs/mmdetection/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 965, in __init__
self._reset(loader, first_iter=True)
File "/home/christ/miniconda3/envs/mmdetection/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 996, in _reset
self._try_put_index()
File "/home/christ/miniconda3/envs/mmdetection/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1230, in _try_put_index
index = self._next_index()
File "/home/christ/miniconda3/envs/mmdetection/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 521, in _next_index
return next(self._sampler_iter) # may raise StopIteration
File "/home/christ/miniconda3/envs/mmdetection/lib/python3.8/site-packages/torch/utils/data/sampler.py", line 226, in __iter__
for idx in self.sampler:
File "/home/christ/dev/repos/railsight/mmdetection-2.25.3/mmdet/datasets/samplers/group_sampler.py", line 36, in __iter__
indices = np.concatenate(indices)
File "<__array_function__ internals>", line 180, in concatenate
ValueError: need at least one array to concatenate
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/home/christ/miniconda3/envs/mmdetection/lib/python3.8/multiprocessing/popen_fork.py", line 27, in poll
pid, sts = os.waitpid(self.pid, flag)
File "/home/christ/miniconda3/envs/mmdetection/lib/python3.8/site-packages/torch/utils/data/_utils/signal_handling.py", line 66, in handler
_error_if_any_worker_fails()
RuntimeError: DataLoader worker (pid 35413) is killed by signal: Terminated.
This is the error message I am faced with when trying to train using SSD with MMDetection. I have checked through my dataset and it works with faster_rcnn so I am not understanding why I am having such an issue with the SSD training. Any advice would be great!
_base_ = '../ssd/ssd300_coco.py'
dataset_type = 'CocoDataset'
classes = ('pantograph',)
data = dict(
train=dict(
img_prefix='configs/pantograph/train/',
classes=classes,
ann_file='configs/pantograph/train/SSDTrain.json',
dataset=dict(
ann_file='configs/pantograph/train/SSDTrain.json',
img_prefix='configs/pantograph/train/')),
val=dict(
img_prefix='configs/pantograph/val/',
classes=classes,
ann_file='configs/pantograph/val/SSDVal.json'),
test=dict(
img_prefix='configs/pantograph/test/',
classes=classes,
ann_file='configs/pantograph/test/SSDTest.json'))
Above is my custom SSD config that I tried to run. I have double checked the file locations and made sure they are all correct.
mmdet has a very good community, you can try to look at this link to solve your problem. Shortly, you should change your classes = ('pantograph',) as the following codes
cfg.metainfo = {
'classes': ('balloon', ),
'palette': [
(220, 20, 60),
]
}

How to resolve "MPS Framework doesn't support float64" on M1 Mac

I am trying to train a YOLO model on a custom dataset using YOLOv8 Ultralytics, using M1 MacBook Pro MPS acceleration which is supported by PyTorch but I am getting the following error while executing the train command.
Command:
!yolo task=detect mode=train model=yolov8s.pt data={HOME}/datasets/data.yaml epochs=25 device=mps
Error Message:
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.10/site-packages/ultralytics/yolo/cli.py", line 56, in cli
func(cfg)
File "/opt/homebrew/lib/python3.10/site-packages/hydra/main.py", line 79, in decorated_main
return task_function(cfg_passthrough)
File "/opt/homebrew/lib/python3.10/site-packages/ultralytics/yolo/v8/detect/train.py", line 207, in train
model.train(**cfg)
File "/opt/homebrew/lib/python3.10/site-packages/ultralytics/yolo/engine/model.py", line 193, in train
self.trainer.train()
File "/opt/homebrew/lib/python3.10/site-packages/ultralytics/yolo/engine/trainer.py", line 185, in train
self._do_train(int(os.getenv("RANK", -1)), world_size)
File "/opt/homebrew/lib/python3.10/site-packages/ultralytics/yolo/engine/trainer.py", line 301, in _do_train
self.loss, self.loss_items = self.criterion(preds, batch)
File "/opt/homebrew/lib/python3.10/site-packages/ultralytics/yolo/v8/detect/train.py", line 77, in criterion
return self.compute_loss(preds, batch)
File "/opt/homebrew/lib/python3.10/site-packages/ultralytics/yolo/v8/detect/train.py", line 168, in __call__
targets = self.preprocess(targets.to(self.device), batch_size, scale_tensor=imgsz[[1, 0, 1, 0]])
TypeError: Cannot convert a MPS Tensor to float64 dtype as the MPS framework doesn't support float64. Please use float32 instead.
Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.
Is there any way to get around this issue and use MPS for training?
I have tried looking for this issue on PyTorch's GitHub conversation, but got no simple solution.
Edit:
I have set HYDRA_FULL_ERROR to 1, and this is the updated error traceback:
Error executing job with overrides: ['task=detect', 'mode=train', 'model=yolov8s.pt', 'data=/Users/aditya_nemiwal/Documents/C++/Python/WiDS_Week3_3/datasets/data.yaml', 'epochs=25', 'device=mps']
Traceback (most recent call last):
File "/opt/homebrew/bin/yolo", line 8, in <module>
sys.exit(cli())
File "/opt/homebrew/lib/python3.10/site-packages/hydra/main.py", line 90, in decorated_main
_run_hydra(
File "/opt/homebrew/lib/python3.10/site-packages/hydra/_internal/utils.py", line 394, in _run_hydra
_run_app(
File "/opt/homebrew/lib/python3.10/site-packages/hydra/_internal/utils.py", line 457, in _run_app
run_and_report(
File "/opt/homebrew/lib/python3.10/site-packages/hydra/_internal/utils.py", line 222, in run_and_report
raise ex
File "/opt/homebrew/lib/python3.10/site-packages/hydra/_internal/utils.py", line 219, in run_and_report
return func()
File "/opt/homebrew/lib/python3.10/site-packages/hydra/_internal/utils.py", line 458, in <lambda>
lambda: hydra.run(
File "/opt/homebrew/lib/python3.10/site-packages/hydra/_internal/hydra.py", line 132, in run
_ = ret.return_value
File "/opt/homebrew/lib/python3.10/site-packages/hydra/core/utils.py", line 260, in return_value
raise self._return_value
File "/opt/homebrew/lib/python3.10/site-packages/hydra/core/utils.py", line 186, in run_job
ret.return_value = task_function(task_cfg)
File "/opt/homebrew/lib/python3.10/site-packages/ultralytics/yolo/cli.py", line 56, in cli
func(cfg)
File "/opt/homebrew/lib/python3.10/site-packages/hydra/main.py", line 79, in decorated_main
return task_function(cfg_passthrough)
File "/opt/homebrew/lib/python3.10/site-packages/ultralytics/yolo/v8/detect/train.py", line 207, in train
model.train(**cfg)
File "/opt/homebrew/lib/python3.10/site-packages/ultralytics/yolo/engine/model.py", line 193, in train
self.trainer.train()
File "/opt/homebrew/lib/python3.10/site-packages/ultralytics/yolo/engine/trainer.py", line 185, in train
self._do_train(int(os.getenv("RANK", -1)), world_size)
File "/opt/homebrew/lib/python3.10/site-packages/ultralytics/yolo/engine/trainer.py", line 301, in _do_train
self.loss, self.loss_items = self.criterion(preds, batch)
File "/opt/homebrew/lib/python3.10/site-packages/ultralytics/yolo/v8/detect/train.py", line 77, in criterion
return self.compute_loss(preds, batch)
File "/opt/homebrew/lib/python3.10/site-packages/ultralytics/yolo/v8/detect/train.py", line 168, in __call__
targets = self.preprocess(targets.to(self.device), batch_size, scale_tensor=imgsz[[1, 0, 1, 0]])
TypeError: Cannot convert a MPS Tensor to float64 dtype as the MPS framework doesn't support float64. Please use float32 instead.

Tensors in list passed to 'inputs' of 'MergeSummary' Op have types [bool, bool, bool, string, string] that do not match expected type string

I am taking this error in uwgan(GAN method)
I'm trying to adapt this code to Tf2: https://github.com/infrontofme/UWGAN_UIE
g_sum = tf.compat.v1.summary.merge([self.z_sum, self.d__sum, self.G_sum, self.d_loss_fake_sum, self.g_loss_sum])
d_sum = tf.compat.v1.summary.merge([self.z_sum, self.d_sum, self.d_loss_real_sum, self.d_loss_sum])
writer = tf.compat.v1.summary.FileWriter(config.log_dir, self.sess.graph)
`Traceback (most recent call last):
File "C:\Users\STEM_WS__AI\Anaconda3\envs\uwgan\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 438, in _apply_op_helper
as_ref=input_arg.is_ref)
File "C:\Users\STEM_WS__AI\Anaconda3\envs\uwgan\lib\site-packages\tensorflow\python\framework\ops.py", line 1608, in internal_convert_n_to_tensor
ctx=ctx))
File "C:\Users\STEM_WS__AI\Anaconda3\envs\uwgan\lib\site-packages\tensorflow\python\profiler\trace.py", line 163, in wrapped
return func(*args, **kwargs)
File "C:\Users\STEM_WS__AI\Anaconda3\envs\uwgan\lib\site-packages\tensorflow\python\framework\ops.py", line 1509, in convert_to_tensor
(dtype.name, value.dtype.name, value))
ValueError: Tensor conversion requested dtype string for Tensor with dtype bool: <tf.Tensor 'z_1/write_summary/Const:0' shape=() dtype=bool>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "uwgan_main.py", line 81, in <module>
tf.compat.v1.app.run()
File "C:\Users\STEM_WS__AI\Anaconda3\envs\uwgan\lib\site-packages\tensorflow\python\platform\app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "C:\Users\STEM_WS__AI\Anaconda3\envs\uwgan\lib\site-packages\absl\app.py", line 312, in run
_run_main(main, args)
File "C:\Users\STEM_WS__AI\Anaconda3\envs\uwgan\lib\site-packages\absl\app.py", line 258, in _run_main
sys.exit(main(argv))
File "uwgan_main.py", line 72, in main
wgan.train(FLAGS)
File "D:\UWGAN\UWGAN\uwgan_model.py", line 167, in train
g_sum = tf.compat.v1.summary.merge([self.z_sum, self.d__sum, self.G_sum, self.d_loss_fake_sum, self.g_loss_sum])
File "C:\Users\STEM_WS__AI\Anaconda3\envs\uwgan\lib\site-packages\tensorflow\python\summary\summary.py", line 371, in merge
val = _gen_logging_ops.merge_summary(inputs=inputs, name=name)
File "C:\Users\STEM_WS__AI\Anaconda3\envs\uwgan\lib\site-packages\tensorflow\python\ops\gen_logging_ops.py", line 468, in merge_summary
"MergeSummary", inputs=inputs, name=name)
File "C:\Users\STEM_WS__AI\Anaconda3\envs\uwgan\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 460, in _apply_op_helper
(prefix, dtype.name))
TypeError: Tensors in list passed to 'inputs' of 'MergeSummary' Op have types [bool, bool, bool, string, string] that do not match expected type string.`
help me for this error
I used GAN and i try upgrade to tf2 this code.

TensorFlow KeyError: 'RegexReplace' when predict on DNNClassifier using tf.contrib.predictor.from_saved_model

I am trying to restore an estimator and predict on it.
System Config :
CentOS 7 - x64 - CPU
tensorflow == 1.5
This is how I saved the estimator DNNClassifier
def serving_input_receiver_fn():
inputs = {"embeddings": tf.placeholder(shape=[None], dtype=tf.string)}
return tf.estimator.export.ServingInputReceiver(inputs, inputs)
export_dir = estimator.export_savedmodel(
export_dir_base='models/run7',
serving_input_receiver_fn=serving_input_receiver_fn)
I reloaded it using tf.contrib.predictor.from_saved_model as follows
estimator = tf.contrib.predictor.from_saved_model('model/1528805269/')
but, then I get the error KeyError: 'RegexReplace' on the above line
complete error :
Traceback (most recent call last):
File "app.py", line 38, in <module>
load_model()
File "app.py", line 21, in load_model
estimator = tf.contrib.predictor.from_saved_model('model/1528805269/')
File "/var/www/html/my_project/prj_v4/lib/python3.6/site-packages/tensorflow/contrib/predictor/predictor_factories.py", line 129, in from_saved_model
graph=graph)
File "/var/www/html/my_project/prj_v4/lib/python3.6/site-packages/tensorflow/contrib/predictor/saved_model_predictor.py", line 156, in __init__
loader.load(self._session, tags.split(','), export_dir)
File "/var/www/html/my_project/prj_v4/lib/python3.6/site-packages/tensorflow/python/saved_model/loader_impl.py", line 216, in load
saver = tf_saver.import_meta_graph(meta_graph_def_to_load, **saver_kwargs)
File "/var/www/html/my_project/prj_v4/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1838, in import_meta_graph
**kwargs)
File "/var/www/html/my_project/prj_v4/lib/python3.6/site-packages/tensorflow/python/framework/meta_graph.py", line 660, in import_scoped_meta_graph
producer_op_list=producer_op_list)
File "/var/www/html/my_project/prj_v4/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 316, in new_func
return func(*args, **kwargs)
File "/var/www/html/my_project/prj_v4/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 433, in import_graph_def
_RemoveDefaultAttrs(op_dict, producer_op_list, graph_def)
File "/var/www/html/my_project/prj_v4/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 211, in _RemoveDefaultAttrs
op_def = op_dict[node.op]
KeyError: 'RegexReplace'
Any Suggestions what might be going wrong ?

some error happened when I run the example code in the theano scan api guide

Win 10 x64, conda, theano 0.9, python 3.6.1, spyder 3.1.4, IPython 6.0.0
When I test the code in scan api tutorial Iterating over the first dimension of a tensor: Calculating a polynomial , i.e.
import theano
import numpy as np
import theano.tensor as T
from theano import In
coefficients = theano.tensor.vector("coefficients")
x = T.scalar("x")
max_coefficients_supported = 10000
# Generate the components of the polynomial
components, updates = theano.scan(fn=lambda coefficient, power, free_variable: coefficient * (free_variable ** power),
outputs_info=None,
sequences=[coefficients, theano.tensor.arange(max_coefficients_supported)],
non_sequences=x)
# Sum them up
polynomial = components.sum()
# Compile a function
calculate_polynomial = theano.function(inputs=[coefficients, x], outputs=polynomial)
spyder throw the error :
ERROR (theano.gof.opt): Optimization failure due to: local_subtensor_merge
ERROR (theano.gof.opt): node: Subtensor{:int64:}(coefficients[0:], ScalarFromTensor.0)
ERROR (theano.gof.opt): TRACEBACK:
ERROR (theano.gof.opt): Traceback (most recent call last):
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 625, in __call__
storage_map[ins] = [self._get_test_value(ins)]
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 581, in _get_test_value
raise AttributeError('%s has no test value %s' % (v, detailed_err_msg))
AttributeError: Elemwise{switch,no_inplace}.0 has no test value
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\opt.py", line 1982, in process_node
replacements = lopt.transform(node)
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\tensor\opt.py", line 3051, in local_subtensor_merge
out = subtens(x, *sl_ins)
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 615, in __call__
node = self.make_node(*inputs, **kwargs)
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\tensor\subtensor.py", line 474, in make_node
inputs = tuple(self.my_as_scalar(a) for a in inputs)
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\tensor\subtensor.py", line 474, in <genexpr>
inputs = tuple(self.my_as_scalar(a) for a in inputs)
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\tensor\subtensor.py", line 459, in my_as_scalar
return theano.tensor.scalar_from_tensor(a)
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 639, in __call__
(i, ins, node, detailed_err_msg))
ValueError: Cannot compute test value: input 0 (Elemwise{switch,no_inplace}.0) of Op ScalarFromTensor(Elemwise{switch,no_inplace}.0) missing default value.
ERROR (theano.gof.opt): Optimization failure due to: local_subtensor_merge
ERROR (theano.gof.opt): node: Subtensor{:int64:}(Subtensor{int64::}.0, ScalarFromTensor.0)
ERROR (theano.gof.opt): TRACEBACK:
ERROR (theano.gof.opt): Traceback (most recent call last):
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 625, in __call__
storage_map[ins] = [self._get_test_value(ins)]
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 581, in _get_test_value
raise AttributeError('%s has no test value %s' % (v, detailed_err_msg))
AttributeError: Elemwise{minimum,no_inplace}.0 has no test value
Backtrace when that variable is created:
File "C:\Users\sejab\Miniconda3\lib\site-packages\ipykernel\zmqshell.py", line 533, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "C:\Users\sejab\Miniconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2683, in run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "C:\Users\sejab\Miniconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2793, in run_ast_nodes
if self.run_code(code, result):
File "C:\Users\sejab\Miniconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2847, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-1-a340056dd686>", line 1, in <module>
runfile('D:/WorkSpace/Python/Bayes/temp_temp.py', wdir='D:/WorkSpace/Python/Bayes')
File "C:\Users\sejab\Miniconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile
execfile(filename, namespace)
File "C:\Users\sejab\Miniconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "D:/WorkSpace/Python/Bayes/temp_temp.py", line 25, in <module>
non_sequences=x)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\opt.py", line 1982, in process_node
replacements = lopt.transform(node)
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\tensor\opt.py", line 3033, in local_subtensor_merge
ushape[pos_2]))
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\tensor\opt.py", line 2880, in merge_two_slices
sl2, reverse2 = get_canonical_form_slice(slice2, len2)
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\tensor\subtensor.py", line 155, in get_canonical_form_slice
stop_plus_len = stop + length
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\tensor\var.py", line 128, in __add__
return theano.tensor.basic.add(self, other)
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 639, in __call__
(i, ins, node, detailed_err_msg))
ValueError: Cannot compute test value: input 0 (Elemwise{minimum,no_inplace}.0) of Op Elemwise{add,no_inplace}(Elemwise{minimum,no_inplace}.0, TensorConstant{10000}) missing default value.
Backtrace when that variable is created:
File "C:\Users\sejab\Miniconda3\lib\site-packages\ipykernel\zmqshell.py", line 533, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "C:\Users\sejab\Miniconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2683, in run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "C:\Users\sejab\Miniconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2793, in run_ast_nodes
if self.run_code(code, result):
File "C:\Users\sejab\Miniconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2847, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-1-a340056dd686>", line 1, in <module>
runfile('D:/WorkSpace/Python/Bayes/temp_temp.py', wdir='D:/WorkSpace/Python/Bayes')
File "C:\Users\sejab\Miniconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile
execfile(filename, namespace)
File "C:\Users\sejab\Miniconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "D:/WorkSpace/Python/Bayes/temp_temp.py", line 25, in <module>
non_sequences=x)
ERROR (theano.gof.opt): Optimization failure due to: local_shape_to_shape_i
ERROR (theano.gof.opt): node: Shape(coefficients[0:])
ERROR (theano.gof.opt): TRACEBACK:
ERROR (theano.gof.opt): Traceback (most recent call last):
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 625, in __call__
storage_map[ins] = [self._get_test_value(ins)]
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 581, in _get_test_value
raise AttributeError('%s has no test value %s' % (v, detailed_err_msg))
AttributeError: Elemwise{sub,no_inplace}.0 has no test value
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\opt.py", line 1982, in process_node
replacements = lopt.transform(node)
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\tensor\opt.py", line 1884, in local_shape_to_shape_i
ret = shape_feature.make_vector_shape(node.inputs[0])
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\tensor\opt.py", line 1275, in make_vector_shape
return make_vector(*self.shape_of[r])
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 639, in __call__
(i, ins, node, detailed_err_msg))
ValueError: Cannot compute test value: input 0 (Elemwise{sub,no_inplace}.0) of Op MakeVector{dtype='int64'}(Elemwise{sub,no_inplace}.0) missing default value.
ERROR (theano.gof.opt): Optimization failure due to: local_shape_to_shape_i
ERROR (theano.gof.opt): node: Shape(coefficients)
ERROR (theano.gof.opt): TRACEBACK:
ERROR (theano.gof.opt): Traceback (most recent call last):
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 625, in __call__
storage_map[ins] = [self._get_test_value(ins)]
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 581, in _get_test_value
raise AttributeError('%s has no test value %s' % (v, detailed_err_msg))
AttributeError: Shape_i{0}.0 has no test value
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\opt.py", line 1982, in process_node
replacements = lopt.transform(node)
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\tensor\opt.py", line 1884, in local_shape_to_shape_i
ret = shape_feature.make_vector_shape(node.inputs[0])
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\tensor\opt.py", line 1275, in make_vector_shape
return make_vector(*self.shape_of[r])
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 639, in __call__
(i, ins, node, detailed_err_msg))
ValueError: Cannot compute test value: input 0 (Shape_i{0}.0) of Op MakeVector{dtype='int64'}(Shape_i{0}.0) missing default value.
ERROR (theano.gof.opt): Optimization failure due to: local_shape_to_shape_i
ERROR (theano.gof.opt): node: Shape(coefficients)
ERROR (theano.gof.opt): TRACEBACK:
ERROR (theano.gof.opt): Traceback (most recent call last):
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 625, in __call__
storage_map[ins] = [self._get_test_value(ins)]
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 581, in _get_test_value
raise AttributeError('%s has no test value %s' % (v, detailed_err_msg))
AttributeError: Shape_i{0}.0 has no test value
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\opt.py", line 1982, in process_node
replacements = lopt.transform(node)
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\tensor\opt.py", line 1884, in local_shape_to_shape_i
ret = shape_feature.make_vector_shape(node.inputs[0])
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\tensor\opt.py", line 1275, in make_vector_shape
return make_vector(*self.shape_of[r])
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 639, in __call__
(i, ins, node, detailed_err_msg))
ValueError: Cannot compute test value: input 0 (Shape_i{0}.0) of Op MakeVector{dtype='int64'}(Shape_i{0}.0) missing default value.
ERROR (theano.gof.opt): SeqOptimizer apply <theano.tensor.opt.FusionOptimizer object at 0x000002E6B6947860>
ERROR (theano.gof.opt): Traceback:
ERROR (theano.gof.opt): Traceback (most recent call last):
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 625, in __call__
storage_map[ins] = [self._get_test_value(ins)]
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 581, in _get_test_value
raise AttributeError('%s has no test value %s' % (v, detailed_err_msg))
AttributeError: <float64> has no test value
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\opt.py", line 235, in apply
sub_prof = optimizer.optimize(fgraph)
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\opt.py", line 87, in optimize
ret = self.apply(fgraph, *args, **kwargs)
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\tensor\opt.py", line 7289, in apply
new_outputs = self.optimizer(node)
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\tensor\opt.py", line 7133, in local_fuse
return_list=True)
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 639, in __call__
(i, ins, node, detailed_err_msg))
ValueError: Cannot compute test value: input 0 (<float64>) of Op pow(<float64>, <int64>) missing default value.
ERROR (theano.gof.opt): SeqOptimizer apply <theano.compile.mode.AddDestroyHandler object at 0x000002E6B539FA20>
ERROR (theano.gof.opt): Traceback:
ERROR (theano.gof.opt): Traceback (most recent call last):
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 625, in __call__
storage_map[ins] = [self._get_test_value(ins)]
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 581, in _get_test_value
raise AttributeError('%s has no test value %s' % (v, detailed_err_msg))
AttributeError: Sum{acc_dtype=float64}.0 has no test value
Backtrace when that variable is created:
File "C:\Users\sejab\Miniconda3\lib\site-packages\ipykernel\zmqshell.py", line 533, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "C:\Users\sejab\Miniconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2683, in run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "C:\Users\sejab\Miniconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2793, in run_ast_nodes
if self.run_code(code, result):
File "C:\Users\sejab\Miniconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2847, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-1-a340056dd686>", line 1, in <module>
runfile('D:/WorkSpace/Python/Bayes/temp_temp.py', wdir='D:/WorkSpace/Python/Bayes')
File "C:\Users\sejab\Miniconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile
execfile(filename, namespace)
File "C:\Users\sejab\Miniconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "D:/WorkSpace/Python/Bayes/temp_temp.py", line 27, in <module>
polynomial = components.sum()
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\opt.py", line 235, in apply
sub_prof = optimizer.optimize(fgraph)
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\opt.py", line 87, in optimize
ret = self.apply(fgraph, *args, **kwargs)
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\compile\mode.py", line 103, in apply
fgraph.replace_validate(o, _output_guard(o),
File "C:\Users\sejab\Miniconda3\lib\site-packages\theano\gof\op.py", line 639, in __call__
(i, ins, node, detailed_err_msg))
ValueError: Cannot compute test value: input 0 (Sum{acc_dtype=float64}.0) of Op OutputGuard(Sum{acc_dtype=float64}.0) missing default value.
Backtrace when that variable is created:
File "C:\Users\sejab\Miniconda3\lib\site-packages\ipykernel\zmqshell.py", line 533, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "C:\Users\sejab\Miniconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2683, in run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "C:\Users\sejab\Miniconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2793, in run_ast_nodes
if self.run_code(code, result):
File "C:\Users\sejab\Miniconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2847, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-1-a340056dd686>", line 1, in <module>
runfile('D:/WorkSpace/Python/Bayes/temp_temp.py', wdir='D:/WorkSpace/Python/Bayes')
File "C:\Users\sejab\Miniconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile
execfile(filename, namespace)
File "C:\Users\sejab\Miniconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "D:/WorkSpace/Python/Bayes/temp_temp.py", line 27, in <module>
polynomial = components.sum()
Because other code runs well, it seems theano.function induced the problem. Although I tried use In() to add test value to coefficients and x, the problem also stand there.
Ok, I have found a similar question on the official site Creating a step-function: Optimization failure due to: local_subtensor_merge. It may be caused by Pymc3 default settings. There they gave several ways. I use test values as noted in the last comment and set
theano.config.compute_test_value = "warn"
the errors are removed.

Categories