EdgeFeatureGraphCRF Model and ssvm algorithm , TypeError: No matching signature found

394 views
Skip to first unread message

Hana Jarraya

unread,
Feb 1, 2016, 4:52:05 AM2/1/16
to pystruct
As input, I have this attached file data_train.pkl
While using this algorithm, I have an error No matching signature found
import numpy as np
try:
    import cPickle as pickle
except ImportError:
    import pickle

from pystruct import learners
import pystruct.models as crfs
from pystruct.utils import SaveLogger


data_train = pickle.load(open("data_train_dict.pickle"))
C = 0.01

n_states = 21
print("number of samples: %s" % len(data_train['X']))
class_weights = 1. / np.bincount(np.hstack(data_train['Y']))
class_weights *= 21. / np.sum(class_weights)
print(class_weights)

model = crfs.EdgeFeatureGraphCRF(inference_method='qpbo',
                                 class_weight=class_weights,
                                 symmetric_edge_features=[0, 1],
                                 antisymmetric_edge_features=[2])

experiment_name = "edge_features_one_slack_trainval_%f" % C

ssvm = learners.NSlackSSVM(
    model, verbose=2, C=C, max_iter=100000, n_jobs=-1,
    tol=0.0001, show_loss_every=5,
    logger=SaveLogger(experiment_name + ".pickle", save_every=100),
    inactive_threshold=1e-3, inactive_window=10, batch_size=100)
ssvm.fit(data_train['X'], data_train['Y'])

data_val = pickle.load(open("data_val_dict.pickle"))
y_pred = ssvm.predict(data_val['X'])

# we throw away void superpixels and flatten everything
y_pred, y_true = np.hstack(y_pred), np.hstack(data_val['Y'])
y_pred = y_pred[y_true != 255]
y_true = y_true[y_true != 255]

print("Score on validation set: %f" % np.mean(y_true == y_pred))



this is the detailed error that I have:
number of samples: 386
Training n-slack dual structural SVM
iteration 0
An unexpected error occurred while tokenizing input file /home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.pyc
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (2, 0))
An unexpected error occurred while tokenizing input file /home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.pyc
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (2, 0))
An unexpected error occurred while tokenizing input file /home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.pyc
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (2, 0))
An unexpected error occurred while tokenizing input file /home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.pyc
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (2, 0))
An unexpected error occurred while tokenizing input file /home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.pyc
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (2, 0))
An unexpected error occurred while tokenizing input file /home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.pyc
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (2, 0))
An unexpected error occurred while tokenizing input file /home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.pyc
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (2, 0))
An unexpected error occurred while tokenizing input file /home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.pyc
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (2, 0))








An unexpected error occurred while tokenizing input file /home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.pyc
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (2, 0))
An unexpected error occurred while tokenizing input file /home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.pyc
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (2, 0))
An unexpected error occurred while tokenizing input file /home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.pyc
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (2, 0))
An unexpected error occurred while tokenizing input file /home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.pyc
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (2, 0))
An unexpected error occurred while tokenizing input file /home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.pyc
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (2, 0))
An unexpected error occurred while tokenizing input file /home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.pyc
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (2, 0))
An unexpected error occurred while tokenizing input file /home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.pyc
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (2, 0))
An unexpected error occurred while tokenizing input file /home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.pyc
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (2, 0))








---------------------------------------------------------------------------
JoblibTypeError                           Traceback (most recent call last)
<ipython-input-4-59dfb41725ad> in <module>()
     27     inactive_threshold=1e-3, inactive_window=10, batch_size=100)
     28 
---> 29 ssvm.fit(data_train['X'], data_train['Y'])
     30 
     31 data_val = pickle.load(open("/home/hana/anaconda2/Fingerprint/Fingerprint/data_train.pkl"))

/home/hana/.local/lib/python2.7/site-packages/pystruct/learners/n_slack_ssvm.pyc in fit(self, X, Y, constraints, warm_start, initialize)
    311                         n_jobs=self.n_jobs, verbose=verbose)(
    312                             delayed(find_constraint)(self.model, x, y, self.w)
--> 313                             for x, y in zip(X_b, Y_b))
    314 
    315                     # for each batch, gather new constraints

/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in __call__(self, iterable)
    810                 # consumption.
    811                 self._iterating = False
--> 812             self.retrieve()
    813             # Make sure that we get a last message telling us we are done
    814             elapsed_time = time.time() - self._start_time

/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in retrieve(self)
    760                         # a working pool as they expect.
    761                         self._initialize_pool()
--> 762                 raise exception
    763 
    764     def __call__(self, iterable):

JoblibTypeError: JoblibTypeError
___________________________________________________________________________
Multiprocessing exception:
...........................................................................
/home/hana/anaconda2/lib/python2.7/runpy.py in _run_module_as_main(mod_name='ipykernel.__main__', alter_argv=1)
    157     pkg_name = mod_name.rpartition('.')[0]
    158     main_globals = sys.modules["__main__"].__dict__
    159     if alter_argv:
    160         sys.argv[0] = fname
    161     return _run_code(code, main_globals, None,
--> 162                      "__main__", fname, loader, pkg_name)
        fname = '/home/hana/anaconda2/lib/python2.7/site-packages/ipykernel/__main__.py'
        loader = <pkgutil.ImpLoader instance>
        pkg_name = 'ipykernel'
    163 
    164 def run_module(mod_name, init_globals=None,
    165                run_name=None, alter_sys=False):
    166     """Execute a module's code without importing it

...........................................................................
/home/hana/anaconda2/lib/python2.7/runpy.py in _run_code(code=<code object <module> at 0x7f96ddfae9b0, file "/...2.7/site-packages/ipykernel/__main__.py", line 1>, run_globals={'__builtins__': <module '__builtin__' (built-in)>, '__doc__': None, '__file__': '/home/hana/anaconda2/lib/python2.7/site-packages/ipykernel/__main__.py', '__loader__': <pkgutil.ImpLoader instance>, '__name__': '__main__', '__package__': 'ipykernel', 'app': <module 'ipykernel.kernelapp' from '/home/hana/a...python2.7/site-packages/ipykernel/kernelapp.pyc'>}, init_globals=None, mod_name='__main__', mod_fname='/home/hana/anaconda2/lib/python2.7/site-packages/ipykernel/__main__.py', mod_loader=<pkgutil.ImpLoader instance>, pkg_name='ipykernel')
     67         run_globals.update(init_globals)
     68     run_globals.update(__name__ = mod_name,
     69                        __file__ = mod_fname,
     70                        __loader__ = mod_loader,
     71                        __package__ = pkg_name)
---> 72     exec code in run_globals
        code = <code object <module> at 0x7f96ddfae9b0, file "/...2.7/site-packages/ipykernel/__main__.py", line 1>
        run_globals = {'__builtins__': <module '__builtin__' (built-in)>, '__doc__': None, '__file__': '/home/hana/anaconda2/lib/python2.7/site-packages/ipykernel/__main__.py', '__loader__': <pkgutil.ImpLoader instance>, '__name__': '__main__', '__package__': 'ipykernel', 'app': <module 'ipykernel.kernelapp' from '/home/hana/a...python2.7/site-packages/ipykernel/kernelapp.pyc'>}
     73     return run_globals
     74 
     75 def _run_module_code(code, init_globals=None,
     76                     mod_name=None, mod_fname=None,

...........................................................................
/home/hana/anaconda2/lib/python2.7/site-packages/ipykernel/__main__.py in <module>()
      1 
      2 
----> 3 
      4 if __name__ == '__main__':
      5     from ipykernel import kernelapp as app
      6     app.launch_new_instance()
      7 
      8 
      9 
     10 

...........................................................................
/home/hana/anaconda2/lib/python2.7/site-packages/traitlets/config/application.py in launch_instance(cls=<class 'ipykernel.kernelapp.IPKernelApp'>, argv=None, **kwargs={})
    587         
    588         If a global instance already exists, this reinitializes and starts it
    589         """
    590         app = cls.instance(**kwargs)
    591         app.initialize(argv)
--> 592         app.start()
        app.start = <bound method IPKernelApp.start of <ipykernel.kernelapp.IPKernelApp object>>
    593 
    594 #-----------------------------------------------------------------------------
    595 # utility functions, for convenience
    596 #-----------------------------------------------------------------------------

...........................................................................
/home/hana/anaconda2/lib/python2.7/site-packages/ipykernel/kernelapp.py in start(self=<ipykernel.kernelapp.IPKernelApp object>)
    398         
    399         if self.poller is not None:
    400             self.poller.start()
    401         self.kernel.start()
    402         try:
--> 403             ioloop.IOLoop.instance().start()
    404         except KeyboardInterrupt:
    405             pass
    406 
    407 launch_new_instance = IPKernelApp.launch_instance

...........................................................................
/home/hana/anaconda2/lib/python2.7/site-packages/zmq/eventloop/ioloop.py in start(self=<zmq.eventloop.ioloop.ZMQIOLoop object>)
    146             PollIOLoop.configure(ZMQIOLoop)
    147         return PollIOLoop.instance()
    148     
    149     def start(self):
    150         try:
--> 151             super(ZMQIOLoop, self).start()
        self.start = <bound method ZMQIOLoop.start of <zmq.eventloop.ioloop.ZMQIOLoop object>>
    152         except ZMQError as e:
    153             if e.errno == ETERM:
    154                 # quietly return on ETERM
    155                 pass

...........................................................................
/home/hana/anaconda2/lib/python2.7/site-packages/tornado/ioloop.py in start(self=<zmq.eventloop.ioloop.ZMQIOLoop object>)
    861                 self._events.update(event_pairs)
    862                 while self._events:
    863                     fd, events = self._events.popitem()
    864                     try:
    865                         fd_obj, handler_func = self._handlers[fd]
--> 866                         handler_func(fd_obj, events)
        handler_func = <function null_wrapper>
        fd_obj = <zmq.sugar.socket.Socket object>
        events = 1
    867                     except (OSError, IOError) as e:
    868                         if errno_from_exception(e) == errno.EPIPE:
    869                             # Happens when the client closes the connection
    870                             pass

...........................................................................
/home/hana/anaconda2/lib/python2.7/site-packages/tornado/stack_context.py in null_wrapper(*args=(<zmq.sugar.socket.Socket object>, 1), **kwargs={})
    270         # Fast path when there are no active contexts.
    271         def null_wrapper(*args, **kwargs):
    272             try:
    273                 current_state = _state.contexts
    274                 _state.contexts = cap_contexts[0]
--> 275                 return fn(*args, **kwargs)
        args = (<zmq.sugar.socket.Socket object>, 1)
        kwargs = {}
    276             finally:
    277                 _state.contexts = current_state
    278         null_wrapper._wrapped = True
    279         return null_wrapper

...........................................................................
/home/hana/anaconda2/lib/python2.7/site-packages/zmq/eventloop/zmqstream.py in _handle_events(self=<zmq.eventloop.zmqstream.ZMQStream object>, fd=<zmq.sugar.socket.Socket object>, events=1)
    428             # dispatch events:
    429             if events & IOLoop.ERROR:
    430                 gen_log.error("got POLLERR event on ZMQStream, which doesn't make sense")
    431                 return
    432             if events & IOLoop.READ:
--> 433                 self._handle_recv()
        self._handle_recv = <bound method ZMQStream._handle_recv of <zmq.eventloop.zmqstream.ZMQStream object>>
    434                 if not self.socket:
    435                     return
    436             if events & IOLoop.WRITE:
    437                 self._handle_send()

...........................................................................
/home/hana/anaconda2/lib/python2.7/site-packages/zmq/eventloop/zmqstream.py in _handle_recv(self=<zmq.eventloop.zmqstream.ZMQStream object>)
    460                 gen_log.error("RECV Error: %s"%zmq.strerror(e.errno))
    461         else:
    462             if self._recv_callback:
    463                 callback = self._recv_callback
    464                 # self._recv_callback = None
--> 465                 self._run_callback(callback, msg)
        self._run_callback = <bound method ZMQStream._run_callback of <zmq.eventloop.zmqstream.ZMQStream object>>
        callback = <function null_wrapper>
        msg = [<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>]
    466                 
    467         # self.update_state()
    468         
    469 

...........................................................................
/home/hana/anaconda2/lib/python2.7/site-packages/zmq/eventloop/zmqstream.py in _run_callback(self=<zmq.eventloop.zmqstream.ZMQStream object>, callback=<function null_wrapper>, *args=([<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>],), **kwargs={})
    402         close our socket."""
    403         try:
    404             # Use a NullContext to ensure that all StackContexts are run
    405             # inside our blanket exception handler rather than outside.
    406             with stack_context.NullContext():
--> 407                 callback(*args, **kwargs)
        callback = <function null_wrapper>
        args = ([<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>],)
        kwargs = {}
    408         except:
    409             gen_log.error("Uncaught exception, closing connection.",
    410                           exc_info=True)
    411             # Close the socket on an uncaught exception from a user callback

...........................................................................
/home/hana/anaconda2/lib/python2.7/site-packages/tornado/stack_context.py in null_wrapper(*args=([<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>],), **kwargs={})
    270         # Fast path when there are no active contexts.
    271         def null_wrapper(*args, **kwargs):
    272             try:
    273                 current_state = _state.contexts
    274                 _state.contexts = cap_contexts[0]
--> 275                 return fn(*args, **kwargs)
        args = ([<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>],)
        kwargs = {}
    276             finally:
    277                 _state.contexts = current_state
    278         null_wrapper._wrapped = True
    279         return null_wrapper

...........................................................................
/home/hana/anaconda2/lib/python2.7/site-packages/ipykernel/kernelbase.py in dispatcher(msg=[<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>])
    255         if self.control_stream:
    256             self.control_stream.on_recv(self.dispatch_control, copy=False)
    257 
    258         def make_dispatcher(stream):
    259             def dispatcher(msg):
--> 260                 return self.dispatch_shell(stream, msg)
        msg = [<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>]
    261             return dispatcher
    262 
    263         for s in self.shell_streams:
    264             s.on_recv(make_dispatcher(s), copy=False)

...........................................................................
/home/hana/anaconda2/lib/python2.7/site-packages/ipykernel/kernelbase.py in dispatch_shell(self=<ipykernel.ipkernel.IPythonKernel object>, stream=<zmq.eventloop.zmqstream.ZMQStream object>, msg={'buffers': [], 'content': {u'allow_stdin': True, u'code': u'import numpy as np\ntry:\n    import cPickle a...validation set: %f" % np.mean(y_true == y_pred))', u'silent': False, u'stop_on_error': True, u'store_history': True, u'user_expressions': {}}, 'header': {'date': '2016-02-01T10:33:02.603770', u'msg_id': u'AE801FC2A09149FDBEE35EEC681D73F4', u'msg_type': u'execute_request', u'session': u'09378AD7BC7B4F779E96BABCCDC9BFBF', u'username': u'username', u'version': u'5.0'}, 'metadata': {}, 'msg_id': u'AE801FC2A09149FDBEE35EEC681D73F4', 'msg_type': u'execute_request', 'parent_header': {}})
    207             self.log.error("UNKNOWN MESSAGE TYPE: %r", msg_type)
    208         else:
    209             self.log.debug("%s: %s", msg_type, msg)
    210             self.pre_handler_hook()
    211             try:
--> 212                 handler(stream, idents, msg)
        handler = <bound method IPythonKernel.execute_request of <ipykernel.ipkernel.IPythonKernel object>>
        stream = <zmq.eventloop.zmqstream.ZMQStream object>
        idents = ['09378AD7BC7B4F779E96BABCCDC9BFBF']
        msg = {'buffers': [], 'content': {u'allow_stdin': True, u'code': u'import numpy as np\ntry:\n    import cPickle a...validation set: %f" % np.mean(y_true == y_pred))', u'silent': False, u'stop_on_error': True, u'store_history': True, u'user_expressions': {}}, 'header': {'date': '2016-02-01T10:33:02.603770', u'msg_id': u'AE801FC2A09149FDBEE35EEC681D73F4', u'msg_type': u'execute_request', u'session': u'09378AD7BC7B4F779E96BABCCDC9BFBF', u'username': u'username', u'version': u'5.0'}, 'metadata': {}, 'msg_id': u'AE801FC2A09149FDBEE35EEC681D73F4', 'msg_type': u'execute_request', 'parent_header': {}}
    213             except Exception:
    214                 self.log.error("Exception in message handler:", exc_info=True)
    215             finally:
    216                 self.post_handler_hook()

...........................................................................
/home/hana/anaconda2/lib/python2.7/site-packages/ipykernel/kernelbase.py in execute_request(self=<ipykernel.ipkernel.IPythonKernel object>, stream=<zmq.eventloop.zmqstream.ZMQStream object>, ident=['09378AD7BC7B4F779E96BABCCDC9BFBF'], parent={'buffers': [], 'content': {u'allow_stdin': True, u'code': u'import numpy as np\ntry:\n    import cPickle a...validation set: %f" % np.mean(y_true == y_pred))', u'silent': False, u'stop_on_error': True, u'store_history': True, u'user_expressions': {}}, 'header': {'date': '2016-02-01T10:33:02.603770', u'msg_id': u'AE801FC2A09149FDBEE35EEC681D73F4', u'msg_type': u'execute_request', u'session': u'09378AD7BC7B4F779E96BABCCDC9BFBF', u'username': u'username', u'version': u'5.0'}, 'metadata': {}, 'msg_id': u'AE801FC2A09149FDBEE35EEC681D73F4', 'msg_type': u'execute_request', 'parent_header': {}})
    365         if not silent:
    366             self.execution_count += 1
    367             self._publish_execute_input(code, parent, self.execution_count)
    368 
    369         reply_content = self.do_execute(code, silent, store_history,
--> 370                                         user_expressions, allow_stdin)
        user_expressions = {}
        allow_stdin = True
    371 
    372         # Flush output before sending the reply.
    373         sys.stdout.flush()
    374         sys.stderr.flush()

...........................................................................
/home/hana/anaconda2/lib/python2.7/site-packages/ipykernel/ipkernel.py in do_execute(self=<ipykernel.ipkernel.IPythonKernel object>, code=u'import numpy as np\ntry:\n    import cPickle a...validation set: %f" % np.mean(y_true == y_pred))', silent=False, store_history=True, user_expressions={}, allow_stdin=True)
    170 
    171         reply_content = {}
    172         # FIXME: the shell calls the exception handler itself.
    173         shell._reply_content = None
    174         try:
--> 175             shell.run_cell(code, store_history=store_history, silent=silent)
        shell.run_cell = <bound method ZMQInteractiveShell.run_cell of <ipykernel.zmqshell.ZMQInteractiveShell object>>
        code = u'import numpy as np\ntry:\n    import cPickle a...validation set: %f" % np.mean(y_true == y_pred))'
        store_history = True
        silent = False
    176         except:
    177             status = u'error'
    178             # FIXME: this code right now isn't being used yet by default,
    179             # because the run_cell() call above directly fires off exception

...........................................................................
/home/hana/anaconda2/lib/python2.7/site-packages/IPython/core/interactiveshell.py in run_cell(self=<ipykernel.zmqshell.ZMQInteractiveShell object>, raw_cell=u'import numpy as np\ntry:\n    import cPickle a...validation set: %f" % np.mean(y_true == y_pred))', store_history=True, silent=False, shell_futures=True)
   2897                 self.displayhook.exec_result = result
   2898 
   2899                 # Execute the user code
   2900                 interactivity = "none" if silent else self.ast_node_interactivity
   2901                 self.run_ast_nodes(code_ast.body, cell_name,
-> 2902                    interactivity=interactivity, compiler=compiler, result=result)
        interactivity = 'last_expr'
        compiler = <IPython.core.compilerop.CachingCompiler instance>
   2903 
   2904                 # Reset this so later displayed values do not modify the
   2905                 # ExecutionResult
   2906                 self.displayhook.exec_result = None

...........................................................................
/home/hana/anaconda2/lib/python2.7/site-packages/IPython/core/interactiveshell.py in run_ast_nodes(self=<ipykernel.zmqshell.ZMQInteractiveShell object>, nodelist=[<_ast.Import object>, <_ast.TryExcept object>, <_ast.ImportFrom object>, <_ast.Import object>, <_ast.ImportFrom object>, <_ast.Assign object>, <_ast.Assign object>, <_ast.Assign object>, <_ast.Print object>, <_ast.Assign object>, <_ast.AugAssign object>, <_ast.Assign object>, <_ast.Assign object>, <_ast.Assign object>, <_ast.Expr object>, <_ast.Assign object>, <_ast.Assign object>, <_ast.Assign object>, <_ast.Assign object>, <_ast.Assign object>, ...], cell_name='<ipython-input-4-59dfb41725ad>', interactivity='none', compiler=<IPython.core.compilerop.CachingCompiler instance>, result=<IPython.core.interactiveshell.ExecutionResult object>)
   3001 
   3002         try:
   3003             for i, node in enumerate(to_run_exec):
   3004                 mod = ast.Module([node])
   3005                 code = compiler(mod, cell_name, "exec")
-> 3006                 if self.run_code(code, result):
        self.run_code = <bound method ZMQInteractiveShell.run_code of <ipykernel.zmqshell.ZMQInteractiveShell object>>
        code = <code object <module> at 0x7f969bb03ab0, file "<ipython-input-4-59dfb41725ad>", line 29>
        result = <IPython.core.interactiveshell.ExecutionResult object>
   3007                     return True
   3008 
   3009             for i, node in enumerate(to_run_interactive):
   3010                 mod = ast.Interactive([node])

...........................................................................
/home/hana/anaconda2/lib/python2.7/site-packages/IPython/core/interactiveshell.py in run_code(self=<ipykernel.zmqshell.ZMQInteractiveShell object>, code_obj=<code object <module> at 0x7f969bb03ab0, file "<ipython-input-4-59dfb41725ad>", line 29>, result=<IPython.core.interactiveshell.ExecutionResult object>)
   3061         outflag = 1  # happens in more places, so it's easier as default
   3062         try:
   3063             try:
   3064                 self.hooks.pre_run_code_hook()
   3065                 #rprint('Running code', repr(code_obj)) # dbg
-> 3066                 exec(code_obj, self.user_global_ns, self.user_ns)
        code_obj = <code object <module> at 0x7f969bb03ab0, file "<ipython-input-4-59dfb41725ad>", line 29>
        self.user_global_ns = {'C': 0.01, 'In': ['', u'import numpy as np\ntry:\n    import cPickle a...validation set: %f" % np.mean(y_true == y_pred))', u'import numpy as np\ntry:\n    import cPickle a...validation set: %f" % np.mean(y_true == y_pred))', u'import numpy as np\ntry:\n    import cPickle a...validation set: %f" % np.mean(y_true == y_pred))', u'import numpy as np\ntry:\n    import cPickle a...validation set: %f" % np.mean(y_true == y_pred))'], 'Out': {}, 'SaveLogger': <class 'pystruct.utils.logging.SaveLogger'>, '_': '', '__': '', '___': '', '__builtin__': <module '__builtin__' (built-in)>, '__builtins__': <module '__builtin__' (built-in)>, '__doc__': 'Automatically created module for IPython interactive environment', ...}
        self.user_ns = {'C': 0.01, 'In': ['', u'import numpy as np\ntry:\n    import cPickle a...validation set: %f" % np.mean(y_true == y_pred))', u'import numpy as np\ntry:\n    import cPickle a...validation set: %f" % np.mean(y_true == y_pred))', u'import numpy as np\ntry:\n    import cPickle a...validation set: %f" % np.mean(y_true == y_pred))', u'import numpy as np\ntry:\n    import cPickle a...validation set: %f" % np.mean(y_true == y_pred))'], 'Out': {}, 'SaveLogger': <class 'pystruct.utils.logging.SaveLogger'>, '_': '', '__': '', '___': '', '__builtin__': <module '__builtin__' (built-in)>, '__builtins__': <module '__builtin__' (built-in)>, '__doc__': 'Automatically created module for IPython interactive environment', ...}
   3067             finally:
   3068                 # Reset our crash handler in place
   3069                 sys.excepthook = old_excepthook
   3070         except SystemExit as e:

...........................................................................
/home/hana/anaconda2/<ipython-input-4-59dfb41725ad> in <module>()
     24     model, verbose=2, C=C, max_iter=100000, n_jobs=-1,
     25     tol=0.0001, show_loss_every=5,
     26     logger=SaveLogger(experiment_name + ".pickle", save_every=100),
     27     inactive_threshold=1e-3, inactive_window=10, batch_size=100)
     28 
---> 29 ssvm.fit(data_train['X'], data_train['Y'])
     30 
     31 data_val = pickle.load(open("/home/hana/anaconda2/Fingerprint/Fingerprint/data_train.pkl"))
     32 y_pred = ssvm.predict(data_val['X'])
     33 # we throw away void superpixels and flatten everything

...........................................................................
/home/hana/.local/lib/python2.7/site-packages/pystruct/learners/n_slack_ssvm.py in fit(self=NSlackSSVM(C=0.01, batch_size=100, break_on_bad=...y=5,
      switch_to=None, tol=0.0001, verbose=2), X=[(array([[ 62.,  85.],
       [ 63.,  87.],
       [ 93.,  97.],
       [ 96.,  99.]]), array([[1, 2],
       [2, 1],
       [3, 4],
       [4, 3]], dtype=int32), array([[ 0,  1],
       [ 0, -2],
       [ 0,  0],
       [ 0, -2]], dtype=int32)), (array([[ 150.,  120.],
       [ 155.,  141.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[ 0,  1],
       [ 0, -1]], dtype=int32)), (array([[  36.,  146.],
       [ 195.,  147.],
       [  30.,  159.],
       [ 190.,  161.]]), array([[1, 3],
       [3, 1],
       [2, 4],
       [4, 2]], dtype=int32), array([[ 0,  2],
       [ 0, -1],
       [ 0,  1],
       [ 0, -1]], dtype=int32)), (array([[  54.,  145.],
       [  40.,  167.],
       [  51.,  157.]]), array([[1, 3],
       [3, 1],
       [3, 2],
       [2, 3]], dtype=int32), array([[ 0,  1],
       [ 0, -1],
       [ 0,  2],
       [ 0,  0]], dtype=int32)), (array([[  39.,  122.],
       [  62.,  137.],
  ...],
       [  72.,  161.],
       [  56.,  114.]]), array([[1, 5],
       [5, 1],
       [5, 2],
   ..., 5],
       [3, 4],
       [4, 3]], dtype=int32), array([[ 0,  0],
       [ 0,  2],
       [ 0,  1...,
       [ 0,  1],
       [ 0, -1]], dtype=int32)), (array([[ 40.,  51.],
       [ 38.,  62.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[ 0,  1],
       [ 0, -1]], dtype=int32)), (array([[ 51.,  41.],
       [ 54.,  50.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[ 0,  1],
       [ 0, -1]], dtype=int32)), (array([[ 65.,  45.],
       [ 58.,  55.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[0, 2],
       [0, 0]], dtype=int32)), (array([[ 217.,  112.],
       [ 225.,  134.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[ 0,  1],
       [ 0, -1]], dtype=int32)), (array([[  37.,  118.],
       [  40.,  120.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[ 0,  0],
       [ 0, -2]], dtype=int32)), (array([[  30.,  106.],
       [  78.,  224.],
  ...],
       [  86.,  190.],
       [  83.,  208.]]), array([[ 1,  3],
       [ 3,  1],
       [ 3,  4...,
       [11,  2],
       [ 2, 11]], dtype=int32), array([[ 0,  0],
       [ 0, -2],
       [ 0,  0...,
       [ 0,  1],
       [ 0, -1]], dtype=int32)), (array([[ 47.,  51.],
       [ 30.,  58.],
       [ 70.,  65.],
       [ 68.,  84.]]), array([[1, 2],
       [2, 1],
       [3, 4],
       [4, 3]], dtype=int32), array([[ 0,  2],
       [ 0,  0],
       [ 0,  1],
       [ 0, -1]], dtype=int32)), (array([[ 212.,   59.],
       [ 156.,  111.],
  ...],
       [ 186.,  107.],
       [ 171.,  112.]]), array([[1, 3],
       [3, 1],
       [3, 4],
   ..., 7],
       [8, 2],
       [2, 8]], dtype=int32), array([[ 0,  0],
       [ 0, -2],
       [ 0,  2...,
       [ 0, -3],
       [ 0,  0]], dtype=int32)), (array([[ 225.,  142.],
       [ 225.,  152.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[ 1,  1],
       [-1, -1]], dtype=int32)), (array([[  64.,  105.],
       [  56.,  106.],
  ...],
       [  83.,  110.],
       [  79.,  117.]]), array([[1, 2],
       [2, 1],
       [1, 7],
   ..., 4],
       [5, 6],
       [6, 5]], dtype=int32), array([[ 0,  3],
       [ 0,  0],
       [ 0,  0...,
       [ 0,  0],
       [ 0, -2]], dtype=int32)), (array([[ 213.,   57.],
       [ 224.,   64.],
       [ 188.,   84.],
       [ 165.,   94.]]), array([[1, 2],
       [2, 1],
       [3, 4],
       [4, 3]], dtype=int32), array([[ 0,  0],
       [ 0, -2],
       [ 0,  2],
       [ 0,  0]], dtype=int32)), (array([[  56.,  141.],
       [  56.,  173.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[ 1,  1],
       [-1, -1]], dtype=int32)), (array([[ 35.,  51.],
       [ 30.,  67.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[ 0,  1],
       [ 0, -1]], dtype=int32)), (array([[ 225.,  124.],
       [ 216.,  128.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[0, 2],
       [0, 0]], dtype=int32)), (array([[ 221.,  161.],
       [ 217.,  176.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[ 0,  1],
       [ 0, -1]], dtype=int32)), ...], Y=array([ 3,  3, 10,  3,  3,  3,  3,  3,  3,  3,  ... 4,  8,  8,  4,  4,  4,  4,  8,  4], dtype=int32), constraints=[[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], ...], warm_start=None, initialize=True)
    308                     Y_b = Y[batch]
    309                     indices_b = indices[batch]
    310                     candidate_constraints = Parallel(
    311                         n_jobs=self.n_jobs, verbose=verbose)(
    312                             delayed(find_constraint)(self.model, x, y, self.w)
--> 313                             for x, y in zip(X_b, Y_b))
        x = undefined
        y = undefined
        X_b = [(array([[ 62.,  85.],
       [ 63.,  87.],
       [ 93.,  97.],
       [ 96.,  99.]]), array([[1, 2],
       [2, 1],
       [3, 4],
       [4, 3]], dtype=int32), array([[ 0,  1],
       [ 0, -2],
       [ 0,  0],
       [ 0, -2]], dtype=int32)), (array([[ 150.,  120.],
       [ 155.,  141.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[ 0,  1],
       [ 0, -1]], dtype=int32)), (array([[  36.,  146.],
       [ 195.,  147.],
       [  30.,  159.],
       [ 190.,  161.]]), array([[1, 3],
       [3, 1],
       [2, 4],
       [4, 2]], dtype=int32), array([[ 0,  2],
       [ 0, -1],
       [ 0,  1],
       [ 0, -1]], dtype=int32)), (array([[  54.,  145.],
       [  40.,  167.],
       [  51.,  157.]]), array([[1, 3],
       [3, 1],
       [3, 2],
       [2, 3]], dtype=int32), array([[ 0,  1],
       [ 0, -1],
       [ 0,  2],
       [ 0,  0]], dtype=int32)), (array([[  39.,  122.],
       [  62.,  137.],
  ...],
       [  72.,  161.],
       [  56.,  114.]]), array([[1, 5],
       [5, 1],
       [5, 2],
   ..., 5],
       [3, 4],
       [4, 3]], dtype=int32), array([[ 0,  0],
       [ 0,  2],
       [ 0,  1...,
       [ 0,  1],
       [ 0, -1]], dtype=int32)), (array([[ 40.,  51.],
       [ 38.,  62.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[ 0,  1],
       [ 0, -1]], dtype=int32)), (array([[ 51.,  41.],
       [ 54.,  50.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[ 0,  1],
       [ 0, -1]], dtype=int32)), (array([[ 65.,  45.],
       [ 58.,  55.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[0, 2],
       [0, 0]], dtype=int32)), (array([[ 217.,  112.],
       [ 225.,  134.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[ 0,  1],
       [ 0, -1]], dtype=int32)), (array([[  37.,  118.],
       [  40.,  120.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[ 0,  0],
       [ 0, -2]], dtype=int32)), (array([[  30.,  106.],
       [  78.,  224.],
  ...],
       [  86.,  190.],
       [  83.,  208.]]), array([[ 1,  3],
       [ 3,  1],
       [ 3,  4...,
       [11,  2],
       [ 2, 11]], dtype=int32), array([[ 0,  0],
       [ 0, -2],
       [ 0,  0...,
       [ 0,  1],
       [ 0, -1]], dtype=int32)), (array([[ 47.,  51.],
       [ 30.,  58.],
       [ 70.,  65.],
       [ 68.,  84.]]), array([[1, 2],
       [2, 1],
       [3, 4],
       [4, 3]], dtype=int32), array([[ 0,  2],
       [ 0,  0],
       [ 0,  1],
       [ 0, -1]], dtype=int32)), (array([[ 212.,   59.],
       [ 156.,  111.],
  ...],
       [ 186.,  107.],
       [ 171.,  112.]]), array([[1, 3],
       [3, 1],
       [3, 4],
   ..., 7],
       [8, 2],
       [2, 8]], dtype=int32), array([[ 0,  0],
       [ 0, -2],
       [ 0,  2...,
       [ 0, -3],
       [ 0,  0]], dtype=int32)), (array([[ 225.,  142.],
       [ 225.,  152.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[ 1,  1],
       [-1, -1]], dtype=int32)), (array([[  64.,  105.],
       [  56.,  106.],
  ...],
       [  83.,  110.],
       [  79.,  117.]]), array([[1, 2],
       [2, 1],
       [1, 7],
   ..., 4],
       [5, 6],
       [6, 5]], dtype=int32), array([[ 0,  3],
       [ 0,  0],
       [ 0,  0...,
       [ 0,  0],
       [ 0, -2]], dtype=int32)), (array([[ 213.,   57.],
       [ 224.,   64.],
       [ 188.,   84.],
       [ 165.,   94.]]), array([[1, 2],
       [2, 1],
       [3, 4],
       [4, 3]], dtype=int32), array([[ 0,  0],
       [ 0, -2],
       [ 0,  2],
       [ 0,  0]], dtype=int32)), (array([[  56.,  141.],
       [  56.,  173.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[ 1,  1],
       [-1, -1]], dtype=int32)), (array([[ 35.,  51.],
       [ 30.,  67.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[ 0,  1],
       [ 0, -1]], dtype=int32)), (array([[ 225.,  124.],
       [ 216.,  128.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[0, 2],
       [0, 0]], dtype=int32)), (array([[ 221.,  161.],
       [ 217.,  176.]]), array([[1, 2],
       [2, 1]], dtype=int32), array([[ 0,  1],
       [ 0, -1]], dtype=int32)), ...]
        Y_b = array([ 3,  3, 10,  3,  3,  3,  3,  3,  3,  3,  ...11,  6, 11,  9,  7, 11,  6,  6,  9], dtype=int32)
    314 
    315                     # for each batch, gather new constraints
    316                     for i, x, y, constraint in zip(indices_b, X_b, Y_b,
    317                                                    candidate_constraints):

...........................................................................
/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py in __call__(self=Parallel(n_jobs=-1), iterable=<generator object <genexpr>>)
    807             if pre_dispatch == "all" or n_jobs == 1:
    808                 # The iterable was consumed all at once by the above for loop.
    809                 # No need to wait for async callbacks to trigger to
    810                 # consumption.
    811                 self._iterating = False
--> 812             self.retrieve()
        self.retrieve = <bound method Parallel.retrieve of Parallel(n_jobs=-1)>
    813             # Make sure that we get a last message telling us we are done
    814             elapsed_time = time.time() - self._start_time
    815             self._print('Done %3i out of %3i | elapsed: %s finished',
    816                         (len(self._output), len(self._output),

---------------------------------------------------------------------------
Sub-process traceback:
---------------------------------------------------------------------------
TypeError                                          Mon Feb  1 10:33:02 2016
PID: 4257                    Python 2.7.10: /home/hana/anaconda2/bin/python
...........................................................................
/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in __call__(self=<sklearn.externals.joblib.parallel.BatchedCalls object>)
     67     def __init__(self, iterator_slice):
     68         self.items = list(iterator_slice)
     69         self._size = len(self.items)
     70 
     71     def __call__(self):
---> 72         return [func(*args, **kwargs) for func, args, kwargs in self.items]
     73 
     74     def __len__(self):
     75         return self._size
     76 

...........................................................................
/home/hana/.local/lib/python2.7/site-packages/pystruct/utils/inference.pyc in find_constraint(model=EdgeFeatureGraphCRF(n_states: 11, inference_method: qpbo, n_features: 2, n_edge_features: 2), x=(array([[ 62.,  85.],
       [ 63.,  87.],
       [ 93.,  97.],
       [ 96.,  99.]]), array([[1, 2],
       [2, 1],
       [3, 4],
       [4, 3]], dtype=int32), array([[ 0,  1],
       [ 0, -2],
       [ 0,  0],
       [ 0, -2]], dtype=int32)), y=3, w=array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  ...,  0.,  0.,  0.,  0.,
        0.,  0.,  0.,  0.]), y_hat=None, relaxed=True, compute_difference=True)
     60     joint_feature(x, y_hat), not djoint_feature, we can optionally skip computing joint_feature(x, y)
     61     using compute_differences=False
     62     """
     63 
     64     if y_hat is None:
---> 65         y_hat = model.loss_augmented_inference(x, y, w, relaxed=relaxed)
     66     joint_feature = model.joint_feature
     67     if getattr(model, 'rescale_C', False):
     68         delta_joint_feature = -joint_feature(x, y_hat, y)
     69     else:

...........................................................................
/home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.pyc in loss_augmented_inference(self=EdgeFeatureGraphCRF(n_states: 11, inference_method: qpbo, n_features: 2, n_edge_features: 2), x=(array([[ 62.,  85.],
       [ 63.,  87.],
       [ 93.,  97.],
       [ 96.,  99.]]), array([[1, 2],
       [2, 1],
       [3, 4],
       [4, 3]], dtype=int32), array([[ 0,  1],
       [ 0, -2],
       [ 0,  0],
       [ 0, -2]], dtype=int32)), y=3, w=array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  ...,  0.,  0.,  0.,  0.,
        0.,  0.,  0.,  0.]), relaxed=True, return_energy=False)
    101         self.inference_calls += 1
    102         self._check_size_w(w)
    103         unary_potentials = self._get_unary_potentials(x, w)
    104         pairwise_potentials = self._get_pairwise_potentials(x, w)
    105         edges = self._get_edges(x)
--> 106         loss_augment_unaries(unary_potentials, np.asarray(y), self.class_weight)
    107 
    108         return inference_dispatch(unary_potentials, pairwise_potentials, edges,
    109                                   self.inference_method, relaxed=relaxed,
    110                                   return_energy=return_energy)

...........................................................................
/home/hana/.local/lib/python2.7/site-packages/pystruct/models/utils.so in utils.__pyx_fused_cpdef (src/utils.c:4341)()
     16 
     17 
     18 
     19 
     20 
---> 21 
     22 
     23 
     24 
     25 

TypeError: No matching signature found


data_train.pkl

Andreas Mueller

unread,
Feb 1, 2016, 11:34:22 AM2/1/16
to pyst...@googlegroups.com
Can you try again with n_jobs=1?
--
You received this message because you are subscribed to the Google Groups "pystruct" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pystruct+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andreas Mueller

unread,
Feb 1, 2016, 11:35:32 AM2/1/16
to pyst...@googlegroups.com
Also, what are the types of unary_potentials, np.asarray(y) and self.class_weight in the line the error is raised?



On 02/01/2016 04:52 AM, Hana Jarraya wrote:

hana jarraya

unread,
Feb 1, 2016, 11:39:43 AM2/1/16
to pyst...@googlegroups.com
I try it with n_jobs=1.
It gives me this error:

Training n-slack dual structural SVM
iteration 0
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-31-34c65823a41e> in <module>()
     32 Y=data_train['Y']
     33 #print Y
---> 34 ssvm.fit(data_train['X'], data_train['Y'])
     35 data_val = pickle.load(open("/home/hana/anaconda2/Fingerprint/Fingerprint/data_train.pkl"))
     36 y_pred = ssvm.predict(data_train['X'])

/home/hana/.local/lib/python2.7/site-packages/pystruct/learners/n_slack_ssvm.pyc in fit(self, X, Y, constraints, warm_start, initialize)

    311                         n_jobs=self.n_jobs, verbose=verbose)(
    312                             delayed(find_constraint)(self.model, x, y, self.w)
--> 313                             for x, y in zip(X_b, Y_b))
    314 
    315                     # for each batch, gather new constraints

/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in 
__call__(self, iterable)
    802             self._iterating = True
    803 
--> 804             while self.dispatch_one_batch(iterator):
    805                 pass
    806 

/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in dispatch_one_batch(self, iterator)
    660                 return False
    661             else:
--> 662                 self._dispatch(tasks)
    663                 return True
    664 

/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in _dispatch(self, batch)
    568 
    569         if self._pool is None:
--> 570             job = ImmediateComputeBatch(batch)
    571             self._jobs.append(job)
    572             self.n_dispatched_batches += 1

/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in __init__(self, batch)
    181         # Don't delay the application, to avoid keeping the input
    182         # arguments in memory
--> 183         self.results = batch()
    184 
    185     def get(self):

/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in __call__(self)
     70 
     71     def __call__(self):
---> 72         return [func(*args, **kwargs) for func, args, kwargs in self.items]
     73 
     74     def __len__(self):

/home/hana/.local/lib/python2.7/site-packages/pystruct/utils/inference.pyc in find_constraint(model, x, y, w, y_hat, relaxed, compute_difference)

     63 
     64     if y_hat is None:
---> 65         y_hat = model.loss_augmented_inference(x, y, w, relaxed=relaxed)
     66     joint_feature = model.joint_feature
     67     if getattr(model, 'rescale_C', False):

/home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.pyc in loss_augmented_inference(self, x, y, w, relaxed, return_energy)

    104         pairwise_potentials = self._get_pairwise_potentials(x, w)
    105         edges = self._get_edges(x)
--> 106         loss_augment_unaries(unary_potentials, np.asarray(y), self.class_weight)
    107 
    108         return inference_dispatch(unary_potentials, pairwise_potentials, edges,

utils.pyx in utils.__pyx_fused_cpdef (src/utils.c:4341)()


TypeError: No matching signature found

--
You received this message because you are subscribed to a topic in the Google Groups "pystruct" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pystruct/xDmrW0Xf3mw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pystruct+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Hana Jarraya
PhD student in
Computer Sciences
(+216) 96 11 05 12
(+33)7 53 95 28 50
(+34)6 31 36 94 65
Spain

hana jarraya

unread,
Feb 1, 2016, 11:42:34 AM2/1/16
to pyst...@googlegroups.com

Should I change the unary_potentials, np.asarray(y) and self.class_weight because I do not know about their types.

Andreas Mueller

unread,
Feb 1, 2016, 11:48:08 AM2/1/16
to pyst...@googlegroups.com
Use the ipython debugger (I think you're in IPython anyhow?).
If you ran it in IPython or the Notebook, just do %debug
then you can check the types of the variables.

hana jarraya

unread,
Feb 1, 2016, 12:14:57 PM2/1/16
to pyst...@googlegroups.com
I still have this error :
loss_augment_unaries(unary_potentials, np.asarray(y), self.class_weight)
  File "utils.pyx", line 21, in utils.__pyx_fused_cpdef (src/utils.c:4341)

TypeError: No matching signature found
Could you please give me more details how i can fix it!

Andreas Mueller

unread,
Feb 1, 2016, 1:31:55 PM2/1/16
to pyst...@googlegroups.com


On 02/01/2016 12:14 PM, hana jarraya wrote:
I still have this error :
loss_augment_unaries(unary_potentials, np.asarray(y), self.class_weight)
  File "utils.pyx", line 21, in utils.__pyx_fused_cpdef (src/utils.c:4341)
TypeError: No matching signature found
Could you please give me more details how i can fix it!
Well, I need to know the types of the three variables that are passed, which you can find out using the debugger.

hana jarraya

unread,
Feb 2, 2016, 11:18:29 AM2/2/16
to pyst...@googlegroups.com
Hi,

I am sorry but I was trying to do by debugging.
This is what i found:
(Pdb) n

Training n-slack dual structural SVM
iteration 0
TypeError: TypeErro... found',)
> /home/hana/graphSegmentation.py(32)<module>()
-> ssvm.fit(data_train['X'], data_train['Y'])
(Pdb) n
--Return--
> /home/hana/graphSegmentation.py(32)<module>()->None
-> ssvm.fit(data_train['X'], data_train['Y'])
(Pdb) n
Traceback (most recent call last):
  File "/home/hana/graphSegmentation.py", line 32, in <module>

    ssvm.fit(data_train['X'], data_train['Y'])
  File "/home/hana/.local/lib/python2.7/site-packages/pystruct/learners/n_slack_ssvm.py", line 313, in fit

    for x, y in zip(X_b, Y_b))
  File "/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 804, in __call__
    while self.dispatch_one_batch(iterator):
  File "/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 662, in dispatch_one_batch
    self._dispatch(tasks)
  File "/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 570, in _dispatch
    job = ImmediateComputeBatch(batch)
  File "/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 183, in __init__
    self.results = batch()
  File "/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 72, in __call__

    return [func(*args, **kwargs) for func, args, kwargs in self.items]
  File "/home/hana/.local/lib/python2.7/site-packages/pystruct/utils/inference.py", line 65, in find_constraint

    y_hat = model.loss_augmented_inference(x, y, w, relaxed=relaxed)
  File "/home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.py", line 106, in loss_augmented_inference

    loss_augment_unaries(unary_potentials, np.asarray(y), self.class_weight)
  File "utils.pyx", line 21, in utils.__pyx_fused_cpdef (src/utils.c:4341)
TypeError: No matching signature found
Exception AttributeError: "'NoneType' object has no attribute 'path'" in <function _remove at 0x7efe885d2668> ignored

Andreas Mueller

unread,
Feb 2, 2016, 3:11:25 PM2/2/16
to pyst...@googlegroups.com
So after the type error, you should get a prompt like you did before.
And then you can run
type(unary_potentials), type(np.asarray(y)), type(self.class_weight)

and tell me what you found. Or find someone that is more familiar with python debugging?

hana jarraya

unread,
Feb 3, 2016, 11:56:25 AM2/3/16
to pyst...@googlegroups.com
This is what i found when i print the type variables:
hana@CVC162:~$ python /home/hana/graphSegmentation.py
number of samples: 386
> /home/hana/graphSegmentation.py(27)<module>()

-> ssvm.fit(data_train['X'], data_train['Y'])
(Pdb) n
Training n-slack dual structural SVM
iteration 0
I am here!!!!!!!!!!!!!!
type <type 'numpy.ndarray'>
('UNary potentials', array([[ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.]]), 'y', array(3, dtype=int32), 'classWeight', array([ 0.20680325,  0.16973475,  0.78225579,  0.21941321,  3.59837663,
        1.4993236 ,  0.58038333,  2.24898539,  1.79918832,  8.99594158,
        0.89959416]))
TypeError: TypeErro... found',)
> /home/hana/graphSegmentation.py(27)<module>()

-> ssvm.fit(data_train['X'], data_train['Y'])
(Pdb) n
--Return--
> /home/hana/graphSegmentation.py(27)<module>()->None

-> ssvm.fit(data_train['X'], data_train['Y'])
(Pdb) n
Traceback (most recent call last):
  File "/home/hana/graphSegmentation.py", line 27, in <module>

    ssvm.fit(data_train['X'], data_train['Y'])
  File "/home/hana/.local/lib/python2.7/site-packages/pystruct/learners/n_slack_ssvm.py", line 313, in fit
    for x, y in zip(X_b, Y_b))
  File "/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 804, in __call__
    while self.dispatch_one_batch(iterator):
  File "/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 662, in dispatch_one_batch
    self._dispatch(tasks)
  File "/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 570, in _dispatch
    job = ImmediateComputeBatch(batch)
  File "/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 183, in __init__
    self.results = batch()
  File "/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 72, in __call__
    return [func(*args, **kwargs) for func, args, kwargs in self.items]
  File "/home/hana/.local/lib/python2.7/site-packages/pystruct/utils/inference.py", line 65, in find_constraint
    y_hat = model.loss_augmented_inference(x, y, w, relaxed=relaxed)
  File "/home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.py", line 109, in loss_augmented_inference

    loss_augment_unaries(unary_potentials, np.asarray(y), self.class_weight)
  File "utils.pyx", line 21, in utils.__pyx_fused_cpdef (src/utils.c:4341)
TypeError: No matching signature found
Exception AttributeError: "'NoneType' object has no attribute 'path'" in <function _remove at 0x7f5471481668> ignored

Andreas Mueller

unread,
Feb 3, 2016, 1:03:37 PM2/3/16
to pyst...@googlegroups.com
Can you also give the dtype of the arrays?
It might be because y is int32. Are you on 32 or 64 bit?
Try using data_train['Y'].astype(np.int64)

hana jarraya

unread,
Feb 3, 2016, 2:14:50 PM2/3/16
to pyst...@googlegroups.com
I work with 64 bit.
I tried data_train['Y'].astype(np.int64), but the same error.
I give all the arrays type but the same error:


Training n-slack dual structural SVM
iteration 0
I am here!!!!!!!!!!!!!!
Unary potentials <type 'numpy.ndarray'>
type of y <type 'numpy.ndarray'>
type of class weights <type 'numpy.ndarray'>
('UNary potentials=', array([[ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],

       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.]]), 'y=', array(3), 'classWeight=', array([ 0.20680325,  0.16973475,  0.78225579,  0.21941321,  3.59837663,

        1.4993236 ,  0.58038333,  2.24898539,  1.79918832,  8.99594158,
        0.89959416]))
TypeError: TypeErro... found',)
> /home/hana/graphSegmentation.py(27)<module>()
-> ssvm.fit(data_train['X'], np.array(data_train['Y']).astype(np.int64))

(Pdb) n
--Return--
> /home/hana/graphSegmentation.py(27)<module>()->None
-> ssvm.fit(data_train['X'], np.array(data_train['Y']).astype(np.int64))

(Pdb) n
Traceback (most recent call last):
  File "/home/hana/graphSegmentation.py", line 27, in <module>
    ssvm.fit(data_train['X'], np.array(data_train['Y']).astype(np.int64))

  File "/home/hana/.local/lib/python2.7/site-packages/pystruct/learners/n_slack_ssvm.py", line 313, in fit
    for x, y in zip(X_b, Y_b))
  File "/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 804, in __call__
    while self.dispatch_one_batch(iterator):
  File "/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 662, in dispatch_one_batch
    self._dispatch(tasks)
  File "/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 570, in _dispatch
    job = ImmediateComputeBatch(batch)
  File "/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 183, in __init__
    self.results = batch()
  File "/home/hana/.local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 72, in __call__
    return [func(*args, **kwargs) for func, args, kwargs in self.items]
  File "/home/hana/.local/lib/python2.7/site-packages/pystruct/utils/inference.py", line 65, in find_constraint
    y_hat = model.loss_augmented_inference(x, y, w, relaxed=relaxed)
  File "/home/hana/.local/lib/python2.7/site-packages/pystruct/models/crf.py", line 111, in loss_augmented_inference

    loss_augment_unaries(unary_potentials, np.asarray(y), self.class_weight)
  File "utils.pyx", line 21, in utils.__pyx_fused_cpdef (src/utils.c:4341)
TypeError: No matching signature found
Exception AttributeError: "'NoneType' object has no attribute 'path'" in <function _remove at 0x7f75e5c47668> ignored


Andreas Mueller

unread,
Feb 3, 2016, 2:15:41 PM2/3/16
to pyst...@googlegroups.com
What's the dtype of the unary potentials and class weights?

hana jarraya

unread,
Feb 3, 2016, 2:17:18 PM2/3/16
to pyst...@googlegroups.com
type of Unary potentials <type 'numpy.ndarray'>

type of y <type 'numpy.ndarray'>
type of class weights <type 'numpy.ndarray'>

Andreas Mueller

unread,
Feb 3, 2016, 2:18:09 PM2/3/16
to pyst...@googlegroups.com

There dtype, not the type.

Sent from phone. Please excuse spelling and brevity.

...

hana jarraya

unread,
Feb 3, 2016, 2:26:53 PM2/3/16
to pyst...@googlegroups.com
Thank you for your time, I am very grateful. It does not matter.
When I ask for dtype, it gives this error


print "Unary potentials",np.dtype (unary_potentials)
TypeError: data type not understood


--
You received this message because you are subscribed to a topic in the Google Groups "pystruct" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pystruct/xDmrW0Xf3mw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pystruct+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andreas Mueller

unread,
Feb 3, 2016, 2:38:57 PM2/3/16
to pyst...@googlegroups.com
unary_potentials.dtype
You received this message because you are subscribed to the Google Groups "pystruct" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pystruct+u...@googlegroups.com.

hana jarraya

unread,
Feb 3, 2016, 2:48:36 PM2/3/16
to pyst...@googlegroups.com
Unary potentials float64

hana jarraya

unread,
Feb 3, 2016, 2:51:46 PM2/3/16
to pyst...@googlegroups.com
Unary potentials float64
dtype of y int64
dtype of class weights float64

Andreas Mueller

unread,
Feb 3, 2016, 3:11:32 PM2/3/16
to pyst...@googlegroups.com
I'm trying to run your code to see what is going wrong, but I have trouble loading your pickle file.
What version of python are you using?

hana jarraya

unread,
Feb 3, 2016, 3:13:24 PM2/3/16
to pyst...@googlegroups.com
Python 2.7.10 :: Anaconda 2.4.0 (64-bit)

hana jarraya

unread,
Feb 3, 2016, 3:39:59 PM2/3/16
to pyst...@googlegroups.com
this is the file of data
data_train.pickle

hana jarraya

unread,
Feb 4, 2016, 2:08:19 PM2/4/16
to pyst...@googlegroups.com
Hi,
I solved the previous error it was the size of labels y array. Actually it should has the same size as the nodes_features.
But I get this error and i could not find where is the problem exactly:

File "/home/hana/.local/lib/python2.7/site-packages/pystruct/inference/inference_methods.py", line 78, in inference_dispatch
    **kwargs)
  File "/home/hana/.local/lib/python2.7/site-packages/pystruct/inference/inference_methods.py", line 244, in inference_qpbo
    y = alpha_expansion_general_graph(edges, unary_potentials,pairwise_potentials, random_seed=1)
  File "pyqpbo.pyx", line 600, in pyqpbo.alpha_expansion_general_graph (src/pyqpbo.cpp:7515)
IndexError: index 32 is out of bounds for axis 2 with size 11
Exception AttributeError: "'NoneType' object has no attribute 'path'" in <function _remove at 0x7fc6bf796668> ignored

DO you have any idea to figure out this error?

Andreas Mueller

unread,
Feb 8, 2016, 11:32:24 AM2/8/16
to pyst...@googlegroups.com
Hm, there should be a better error message for the length of y.
Feel free to submit a pull request to improve that.

Again, what are the types of edges, unary_potentials, and pairwise potentials?
Looks like one of them might be None.

hana jarraya

unread,
Feb 8, 2016, 11:37:18 AM2/8/16
to pyst...@googlegroups.com
Hi,
Thanks a lot. Actually my data is graphs. So I tried to map those graphs into the requested format for pystruct Lib.
My errors were how to map the data. First, it was about the nodes and the labels should start from the index zero. Second, every y in Y  must have the same size as the number of the nodes in every graph.

Reply all
Reply to author
Forward
0 new messages