I am imlpementing the Titan graph database with Rexster and Cassandra.
I try to add an edge like this in Ruby with Gremlin:
query = 'a = g.addVertex(null,[name:\'' +
someName +
'\']); g.addEdge(null, g.getVertex(' +
someVertexId + '), a, \'labelname\', [weight:' +
someFloatValue.round(5) + 'd]); g.commit();'
#This formats to the following:
#"a = g.addVertex(null,[name:'myawesomename']); g.addEdge(null, g.getVertex(1337), a, 'labelname', [weight:0.30685d]); g.commit();"
After running this I get the following error:
#<Rexster::Rest::RexsterError: Graph server returned error: javax.script.ScriptException: java.lang.IllegalArgumentException: The type of given name is not a label: labelname>
It seems like I have not defined the label with the name labelname, I got that. However, I can not for the life of me figure out how to add this label so I am able to add this edge to the graph.
Adding vertices works fine by the way.
I am using the rexster_ruby gem which connects to a ubuntu 12.04 machine with titan-server 0.4.0 running the titan.sh script.
The Titan TypeMaker has seen some serious API changes going from 0.3.x to 0.4.x. You can read about how to define an edge label here:
https://github.com/thinkaurelius/titan/wiki/Type-Definition-Overview#creating-edge-labels
It is is recommended that you use the TypeMaker at initialization of your graph, preferably outside of libraries like rexster_ruby, REST, etc. Simply initialize your graph from the Gremlin REPL. Even better, encapsulate those type definitions in a groovy class to maintain your schema.
Related
I have trained my own model, using my own custom dataset, using Yolov4, and I have downloaded the .cfg, .weights and .data files.
When I try to run my model using:
darknet.exe detector test cfg/obj.data cfg/yolov4-og.cfg custom-yolov4-detector_best.weights
I get the error:
Error: l.outputs == params.inputs filters= in the [convolutional]-layer doesn't correspond to classes= or mask= in [yolo]-layer
I don't know if this is an error on my part, with the command I am running, or an error from the model I trained.
Any help would be appreciated.
I am assuming you are using the main darknet repo AlexeyAB. Please make sure you follow the following instructions:
Make sure you assign the correct classes number in the config file.
Change filters=255 to filters=(classes + 5)x3 in the 3
[convolutional] before each [yolo] layer, keep in mind that it only
has to be the last [convolutional] before each of the [yolo] layers
https://github.com/AlexeyAB/darknet/blob/0039fd26786ab5f71d5af725fc18b3f521e7acfd/cfg/yolov3.cfg#L603
https://github.com/AlexeyAB/darknet/blob/0039fd26786ab5f71d5af725fc18b3f521e7acfd/cfg/yolov3.cfg#L689
https://github.com/AlexeyAB/darknet/blob/0039fd26786ab5f71d5af725fc18b3f521e7acfd/cfg/yolov3.cfg#L776
So if classes=1 then should be filters=18. If classes=2 then write filters=21
(Generally filters depends on the classes, coords and number of masks, i.e. filters=(classes + coords + 1)*, where mask is indices of anchors. If mask is absent, then filters=(classes + coords + 1)*num)
Reference: https://github.com/AlexeyAB/darknet#how-to-train-to-detect-your-custom-objects
(class=android.widget.LinearLayout,resource-id=settings_language_selection_toggle,index=1 )
(class=android.widget.RelativeLayout,index=0)
(class=android.widget.LinearLayout,resource-id=widget_frame, index=1)
(class=android.widget.Switch,resource-id=switchWidget, index=0)
/////////////
You can have a look at the hierarchical representation of the elements below
Hierarchy Image View:
***I have tried to reach the switch button by writing the below code on appium Android for java, but it did not work
#AndroidFindBy(xpath ="new UiSelector().resourceId(\"com.idscan.mjcs.sample:id/settings_language_selection_toggle\").instance(1).getChildById(new UiSelector().className(\"android.widget.Switch\")
You using UiSelector syntax in XPath strategy. That is why it isn't working. Try this one:
#AndroidFindBy(uiAutomator = "resourceId(\"settings_language_selection_toggle\").childSelector(className(\"android.widget.Switch\"))")
As you can see here, some boilerplate can be omitted, e.g. new UiSelector().resourceId(...) can be simplified to resourceId(...). One more thing: once you found the root element (LinearLayout with the given resourceId), you can find any child element in the hierarchy using .childSelector() method, nesting doesn't matter.
I am using pyfmi to do simulations with EnergyPlus. I recognized that initializing the individual EnergyPlus models takes quite some time. Therefore, I hope to find a way to initialize the models in parallel. I tried the python library multiprocessing with no success. If it matters, I am on Ubuntu 16.10 and use Python 3.6.
Here is what I want to get done in serial:
fmus = {}
for id in id_list:
chdir(fmu_path+str(id))
fmus[id] = load_fmu('f_' + str(id)+'.fmu',fmu_path+str(id))
fmus[id].initialize(start_time,final_time)
The result is a dictionary with ids as key and the models as value: {id1:FMUModelCS1,id2:FMUModelCS1}
The purpose is to call later the models by their key and do simulations.
Here is my attempt with multiprocessing:
def ep_intialization(id,start_time,final_time):
chdir(fmu_path+str(id))
model = load_fmu('f_' + str(id)+'.fmu',fmu_path+str(id))
model.initialize(start_time,final_time)
return {id:model}
data = ((id,start_time,final_time) for id in id_list)
if __name__ == '__main__':
pool = Pool(processes=cpus)
pool.starmap(ep_intialization, data)
pool.close()
pool.join()
I can see the processes of the models in my system monitor but then the script raise an error because the models are not pickable:
MaybeEncodingError: Error sending result: '[{id2: <pyfmi.fmi.FMUModelCS1 object at 0x561eaf851188>}]'. Reason: 'TypeError('self._fmu,self.callBackFunctions,self.callbacks,self.context,self.variable_list cannot be converted to a Python object for pickling',)'
But I cannot imagine that there is no way to initialize the models in parallel. Other frameworks/libraries than threading/multiprocessing are also welcome.
I saw this answer but it seems that it focuses on the simulations after initialization.
The answer below the one you refer to seems to explain what the problem with multiprocessing and FMU instantiation is.
I tried with pathos suggested in this answer, but run into the same problem:
from pyfmi import load_fmu
from multiprocessing import Pool
from os import chdir
from pathos.multiprocessing import Pool
def ep_intialization(id):
chdir('folder' + str(id))
model = load_fmu('BouncingBall.fmu')
model.initialize(0,10)
return {id:model}
id_list = [1,2]
cpus = 2
data = ((id) for id in id_list)
pool = Pool(cpus)
out = pool.map(ep_intialization, data)
This gives:
MaybeEncodingError: Error sending result: '[{1: <pyfmi.fmi.FMUModelME2 object at 0x564e0c529290>}]'. Reason: 'TypeError('self._context,self._fmu,self.callBackFunctions,self.callbacks cannot be converted to a Python object for pickling',)'
Here is another idea:
I suppose the instantiation is slow because EnergyPlus links plenty of libraries into the FMU. If the components you are modelling all have the same interface (input, output, parameters), you can probably use a single FMU with an additional parameter that switches between the models.
This would be much more efficient: You would only have to instantiate a single FMU and could call it in parallel with different parameters and inputs.
Example:
I have never worked with EnergyPlus, but maybe the following example will illustrate the approach:
You have three variants of a building and you are merely interested in the total heat flux over the entire surface area of buildings as a function of - "weather" (whatever that means - maybe a lot of variables).
Put all three buildings into a single EnergyPlus model and build an if or case clause around them (pseudo code):
if (id_building == 1) {
[model the building one]
elseif (if_building == 2) {
[model the building two]
[...]
Define the "weather" or whatever you need as an input variable for the FMU and define id_building also as a parameter. Define the overall heat flux as output variable.
This would allow you to choose the building before starting the simulation.
The two requirements are:
EnergyPlus Syntax allows if or case structures.
All your models work with the same interface (in our example we have weather as in and a flux as out variables)
There is a dirty workaround for the second requirement: Just define all the variables all your models need and only use what you need in the respective if block.
I've installed titan-0.5.0-hadoop2 with hbase and elasticsearch support
I've loaded the graph with
g = TitanFactory.open('conf/titan-hbase-es.properties')
==>titangraph[hbase:[127.0.0.1]]
and a then I loaded the test application
GraphOfTheGodsFactory.load(g)
Now when I'm trying to create a new index key with:
g.makeKey('userId').dataType(String.class).indexed(Vertex.class).unique().make()
and I got this error:
No signature of method: groovy.lang.MissingMethodException.makeKey() is applicable for argument types: () values: []
Possible solutions: every(), any()
Display stack trace? [yN]
Can someone help me with this ?
when I want to see the indexed keys I see this
g.getIndexedKeys(Vertex.class)
==>reason
==>age
==>name
==>place
I'm not completely following what you are trying to do. It appears that you loaded Graph of the Gods to g and then you want to add userId as a new property to the schema. If that's right, then i think your syntax is wrong, given the Titan 0.5 API. The method for managing the schema is very different from previous versions. Changes to the schema are performed through the ManagementSystem interface which you can get an instance of through:
mgmt = g.getManagementSystem()
The syntax for adding a property then looks something like:
birthDate = mgmt.makePropertyKey('birthDate').dataType(Long.class).cardinality(Cardinality.SINGLE).make()
mgmt.commit()
Note that g.getIndexKeys(Class) is not the appropriate way to get schema information either. You should use the ManagementSystem for that too.
Please see the documentation here for more information.
Problem:
Attempting to use the JYTHON command below and I cannot retrieve the id of my active specification defined at a node-server level in Websphere. I believe its a syntax issue but I'm not sure what.
Code:
AdminConfig.getid('/Cell:mycell/Node:mynode/Server:myserver/J2CActivationSpec:myActiveSpecName/')
Problem Notes:
I do not get a invalid object error so I believe I have the syntax right but it just cannot find the resource even though it exists.
I am using the AdminConfig.getid() as a way to check if the resource already exists in order to do a modify or a create.
If I use the following code: AdminConfig.getid('/J2CActivationSpec:myActiveSpecName/') it will find it but not if I use a more specific path listed above.
Reference Material:
IBM Documentation
Containment paths are always a little tricky. In my (limited) experience, even if you can trace the path by AdminConfig.parents, you may not always be able to use getid.
Are you restricted to using getid? If not, here are some alternatives that will get you an ActivationSpec at the /Cell/Node/Server level:
Querying using AdminConfig.list
This approach will list the Activation Specifications at the specified scope (in our case, the server), and grab the one that has it's name attribute equal to 'myActiveSpecName'.
server = AdminConfig.getid('/Cell:mycell/Node:mynode/Server:myserver')
activationSpec = ''
for as in AdminConfig.list('J2CActivationSpec', server).splitlines():
if AdminConfig.showAttribute(as, 'name') == 'myActiveSpecName'
activationSpec = as
print 'found it :)'
Using Wildcards
This approah uses AdminConfig.list as well, but with a pattern to narrow down your list. If you know your activation spec's configuration begins with myActiveSpecName, then you can do the following:
activationSpec = AdminConfig.list('J2CActivationSpec', 'myActiveSpecName*')