With running the weighted deppWalk implementation I faced with below error. I edit the source code based on issue1 and issu2 and issue3; but, problem still exist. How can I solve that? Is there any other library for weighted deepWalk in python?
Traceback (most recent call last):
File "/usr/local/bin/deepwalk", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.7/dist-packages/deepwalk/__main__.py", line 145, in main
process(args)
File "/usr/local/lib/python3.7/dist-packages/deepwalk/__main__.py", line 73, in process
walks = weighted_random_walk.random_walk(G, num_paths=args.number_walks,path_length=args.walk_length, alpha=0)
File "/usr/local/lib/python3.7/dist-packages/deepwalk/weighted_random_walk.py", line 45, in random_walk
sentence = [nodes[tmp] for tmp in indexList]
File "/usr/local/lib/python3.7/dist-packages/deepwalk/weighted_random_walk.py", line 45, in <listcomp>
sentence = [nodes[tmp] for tmp in indexList]
File "/usr/local/lib/python3.7/dist-packages/networkx/classes/reportviews.py", line 193, in __getitem__
return self._nodes[n]
KeyError: 0
Related
The Java implementation continues to work fine, but the Python implementation, which has also been working fine before the upgrade to 4.10.1, now throws a TypeError on line 89 in adjust of ATNDeserializer.py
Is this a known bug?
Traceback (most recent call last):
File "/Users/vickery/Projects/dgw_processor/dgw_parser.py", line 15, in <module>
from ReqBlockLexer import ReqBlockLexer
File "/Users/vickery/Projects/dgw_processor/ReqBlockLexer.py", line 421, in <module>
class ReqBlockLexer(Lexer):
File "/Users/vickery/Projects/dgw_processor/ReqBlockLexer.py", line 423, in ReqBlockLexer
atn = ATNDeserializer().deserialize(serializedATN())
File "/opt/homebrew/lib/python3.10/site-packages/antlr4/atn/ATNDeserializer.py", line 61, in deserialize
self.reset(data)
File "/opt/homebrew/lib/python3.10/site-packages/antlr4/atn/ATNDeserializer.py", line 91, in reset
temp = [ adjust(c) for c in data ]
File "/opt/homebrew/lib/python3.10/site-packages/antlr4/atn/ATNDeserializer.py", line 91, in <listcomp>
temp = [ adjust(c) for c in data ]
File "/opt/homebrew/lib/python3.10/site-packages/antlr4/atn/ATNDeserializer.py", line 89, in adjust
v = ord(c)
TypeError: ord() expected string of length 1, but int found
Did you regenerate your lexers and parsers?
I have the same error when I used v4.9.2 to generate my code. But when I updated antlr4-python3-runtime to v4.10, the error was fixed.
I had failed to update antlr4-python3-runtime.
CODE:-
from pyTwistyScrambler import scrambler333
scrambler333.get_WCA_scramble()
Result:-
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyTwistyScrambler\__init__.py", line 8, in trimmed_func
return func(*args, **kwargs).strip()
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyTwistyScrambler\scrambler333.py", line 8, in get_WCA_scramble
return _333_SCRAMBLER.call("scramble_333.getRandomScramble")
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\execjs\_abstract_runtime_context.py", line 37, in call
return self._call(name, *args)
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\execjs\_external_runtime.py", line 92, in _call
return self._eval("{identifier}.apply(this, {args})".format(identifier=identifier, args=args))
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\execjs\_external_runtime.py", line 78, in _eval
return self.exec_(code)
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\execjs\_abstract_runtime_context.py", line 18, in exec_
return self._exec_(source)
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\execjs\_external_runtime.py", line 88, in _exec_
return self._extract_result(output)
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\execjs\_external_runtime.py", line 167, in _extract_result
raise ProgramError(value)
execjs._exceptions.ProgramError: SyntaxError: Expected identifier, string or number
I want to make a Rubiks cube scrambler but this module is not working, please help
While running the AutoEncoder model in PyTorch, I found a strange error.
My code:
model = AutoEncoder(num_items, args.inner_layers, num_items, da=args.num_attention, dropout_rate=args.dropout_rate)
item_vector = self.linear1.weight[:, T.LongTensor(batch_item_index[0].astype(np.int32))]
inner_product = item_vector.t().mm(self.linear4.weight.t())
I tried to make the index start from 0 after seeing the explanation that the cause of the batch index was -1 among little similar problems(https://github.com/jwyang/faster-rcnn.pytorch/issues/311), but it did not work.
This is the first time I haven't had a similar question on Stack Overflow, what am I doing wrong?
Traceback (most recent call last):
File "run.py", line 155, in <module>
main()
File "run.py", line 151, in main
train_autoencoder(train_matrix, test_set)
File "run.py", line 86, in train_autoencoder
y_pred = model(batch_item_index, place_correlation)
File "C:\Users\user\anaconda3\envs\saenad\lib\site-packages\torch\nn\modules\module.py", line 491, in __call__
result = self.forward(*input, **kwargs)
File "C:\Users\user\saenad\model.py", line 58, in forward
inner_product = item_vector.t().mm(self.linear4.weight.t())
RuntimeError: invalid argument 1: out of range at c:\programdata\miniconda3\conda-bld\pytorch_1524543037166\work\aten\src\th\generic/THTensor.cpp:454**
I found the item_vector is empty tensor([[]])!
So I added the code to handle an exception if item_vector.Size is 0 with below code.
if item_vector.shape == torch.Size([0]):
continue
<-- it works.
Hope this helps someone with the same error.:)
Can someone help me with the stacktrace generated while using happybase library?
I am trying to pass a dictionary object of python 3.4 in the 'put' method and the following stack trace is generated::
x
b"TWLb'25-Jan-13'"
data_values
{b'Low': b'0.10', b'Date': b'25-Jan-13', b'Volume': b'-', b'Close': b'0.12', b'High': b'0.12', b'Open': b'0.12'}
Traceback (most recent call last):
File "/home/msingal/Desktop/asd/Daily.py", line 63, in insert
hbase_test.insert_data(code, data_format)
File "/home/msingal/Desktop/asd/hbase_test.py", line 56, in insert_data
con.table(ticker, use_prefix=False).put(x, data_values)
File "/usr/lib/python3.4/site-packages/happybase/table.py", line 464, in put
batch.put(row, data)
File "/usr/lib/python3.4/site-packages/happybase/batch.py", line 137, in __exit__
self.send()
File "/usr/lib/python3.4/site-packages/happybase/batch.py", line 60, in send
self._table.connection.client.mutateRows(self._table.name, bms, {})
File "/usr/lib64/python3.4/site-packages/thriftpy/thrift.py", line 198, in _req
return self._recv(_api)
File "/usr/lib64/python3.4/site-packages/thriftpy/thrift.py", line 210, in _recv
fname, mtype, rseqid = self._iprot.read_message_begin()
File "thriftpy/protocol/cybin/cybin.pyx", line 429, in cybin.TCyBinaryProtocol.read_message_begin (thriftpy/protocol/cybin/cybin.c:6325)
File "thriftpy/protocol/cybin/cybin.pyx", line 60, in cybin.read_i32 (thriftpy/protocol/cybin/cybin.c:1546)
File "thriftpy/transport/buffered/cybuffered.pyx", line 65, in thriftpy.transport.buffered.cybuffered.TCyBufferedTransport.c_read (thriftpy/transport/buffered/cybuffered.c:1881)
File "thriftpy/transport/buffered/cybuffered.pyx", line 69, in thriftpy.transport.buffered.cybuffered.TCyBufferedTransport.read_trans (thriftpy/transport/buffered/cybuffered.c:1948)
File "thriftpy/transport/cybase.pyx", line 61, in thriftpy.transport.cybase.TCyBuffer.read_trans (thriftpy/transport/cybase.c:1472)
File "/usr/lib64/python3.4/site-packages/thriftpy/transport/socket.py", line 125, in read
message='TSocket read 0 bytes')
thriftpy.transport.TTransportException: TTransportException(message='TSocket read 0 bytes', type=4)
The lines of code are::
ticker = 'TWLB'
data_values = {b'Low': b'0.10', b'Date': b'25-Jan-13', b'Volume': b'-', b'Close': b'0.12', b'High': b'0.12', b'Open': b'0.12'}
x = (ticker + str(data_values.get(b'Date'))).encode('ASCII')
print('x')
print(x)
print('data_values')
print(data_values)
con.table(ticker, use_prefix=False).put(x, data_values)
Any help on solution and explaination would be apprciated.
I am new to StackOverflow so if my language feels offencive, please forgive me. I have tried to provide all the relevant info but if some info is missing let me know and I will update.
I'm trying to create a graph using gremlin-python, but I can't seem to work out how to add an edge.
Using the standard Gremlin console I can do the following:
gremlin> a = g.addV().next()
==>v[0]
gremlin> b = g.addV().next()
==>v[1]
gremlin> g.V()
==>v[0]
==>v[1]
gremlin> a.addEdge('conn', b)
==>e[2][0-conn->1]
gremlin> g.E()
==>e[2][0-conn->1]
gremlin>
But when trying to do the same via python connected to gremlin server, I can't seem to do the same:
>>> a = g.addV().next()
>>> b = g.addV().next()
>>> g.V().toList()
[v[1519], v[1520]]
>>> a.addEdge('conn', b)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Vertex' object has no attribute 'addEdge'
I've tried various incantations, but can't seem to work it out, and can't find any examples anywhere. Also, I see reference in the Gremlin docs to both addE and addEdge but can't work out what the difference is (neither appear to work above).
Edit: Getting a bit further, but still no luck. It seems GraphTraversal.addE() exists, so if I don't call next() then I can call addE... but still I don't seem to be able to get the arguments something it likes.
>>> a = g.addV()
>>> b = g.addV()
>>> a.addE('foo', b).toList()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Development/matt/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 52, in toList
return list(iter(self))
File "/Development/matt/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 70, in next
return self.__next__()
File "/Development/matt/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 43, in __next__
self.traversal_strategies.apply_strategies(self)
File "/Development/matt/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 284, in apply_strategies
traversal_strategy.apply(traversal)
File "/Development/matt/lib/python2.7/site-packages/gremlin_python/driver/remote_connection.py", line 95, in apply
remote_traversal = self.remote_connection.submit(traversal.bytecode)
File "/Development/matt/lib/python2.7/site-packages/gremlin_python/driver/driver_remote_connection.py", line 53, in submit
traversers = self._loop.run_sync(lambda: self.submit_traversal_bytecode(request_id, bytecode))
File "/Development/matt/lib/python2.7/site-packages/tornado/ioloop.py", line 457, in run_sync
return future_cell[0].result()
File "/Development/matt/lib/python2.7/site-packages/tornado/concurrent.py", line 237, in result
raise_exc_info(self._exc_info)
File "/Development/matt/lib/python2.7/site-packages/tornado/gen.py", line 1021, in run
yielded = self.gen.throw(*exc_info)
File "/Development/matt/lib/python2.7/site-packages/gremlin_python/driver/driver_remote_connection.py", line 73, in submit_traversal_bytecode
traversers = yield self._execute_message(message)
File "/Development/matt/lib/python2.7/site-packages/tornado/gen.py", line 1015, in run
value = future.result()
File "/Development/matt/lib/python2.7/site-packages/tornado/concurrent.py", line 237, in result
raise_exc_info(self._exc_info)
File "/Development/matt/lib/python2.7/site-packages/tornado/gen.py", line 1021, in run
yielded = self.gen.throw(*exc_info)
File "/Development/matt/lib/python2.7/site-packages/gremlin_python/driver/driver_remote_connection.py", line 149, in _execute_message
recv_message = yield response.receive()
File "/Development/matt/lib/python2.7/site-packages/tornado/gen.py", line 1015, in run
value = future.result()
File "/Development/matt/lib/python2.7/site-packages/tornado/concurrent.py", line 237, in result
raise_exc_info(self._exc_info)
File "/Development/matt/lib/python2.7/site-packages/tornado/gen.py", line 1024, in run
yielded = self.gen.send(value)
File "/Development/matt/lib/python2.7/site-packages/gremlin_python/driver/driver_remote_connection.py", line 236, in receive
"{0}: {1}".format(status_code, recv_message["status"]["message"]))
gremlin_python.driver.driver_remote_connection.GremlinServerError: 599: Could not locate method: DefaultGraphTraversal.addE([foo, [AddVertexStep({})]])
As far as I know, addEdge() works on the graph object and addE() works on the graph traversal object. Since you were using g() which is the latter, you need addE().
Seems the following syntax works:
>>> a = g.addV()
>>> b = g.addV()
>>> a.addE('foo').to(b).toList()
[e[1534][1532-foo->1533]]
I'm still not clear on the difference between addE and addEdge but I guess the latter is not available in python and I was confusing the signature of them.