When to return tensors instead of values in Blazeface - tensorflow.js

In the Blazeface demo code and the BlazeFaceModel class, there is a parameter
#param returnTensors (defaults to `false`) Whether to return tensors as
* opposed to values
This parameter is set to false in the demo. When should I want to return tensors instead of values for the Blazeface functionality?

In the event that you want to use the tensors in another model. For example if you wanted to use a model that worked on problems involving humans you would use BlazeFace to detect the human faces then do another classification task on those faces which are tensors returned from the BlazeFace model.

Related

How to implement get_tensor_by_name and predict in tensorflow.js

I want to use Faster rcnn inception v2 to do object detection in tensorflow.js. But i can't find some method in tfjs like get_tensor_by_name and session run for prediction.
In tensorflow (python), the code as the following:
Define input and output node:
# Definite input Tensors for detection_graph
self.image_tensor = self.detection_graph.get_tensor_by_name('image_tensor:0')
# Definite output Tensors for detection_graph
self.detection_boxes = self.detection_graph.get_tensor_by_name('detection_boxes:0')
self.detection_scores = self.detection_graph.get_tensor_by_name('detection_scores:0')
self.detection_classes = self.detection_graph.get_tensor_by_name('detection_classes:0')
self.num_detections = self.detection_graph.get_tensor_by_name('num_detections:0')
Predict:
(boxes, scores, classes, num) = self.sess.run(
[self.detection_boxes, self.detection_scores, self.detection_classes, self.num_detections],
feed_dict={self.image_tensor: image_np_expanded})
Do anyone know how to implement those two part of code in tfjs?
Please help. Thank you!
You don't have a session.run function in tensorflow.Js as there is in Python. In python, you start defining a graph and in the run function, you execute the graph. Tensors and Variables are assigned values in the graph, but the graph defines only the flow of computation, it does not hold any values. The real computation occurs when you run the session. One can create many session where each session can assign different values to the variable, that is why the graph has a get_by_tensor_name which outputs the tensor whose name is given as parameter.
You don't have the same mechanism in Js. You can use the variable as soon as you define them. It means that whenever you define a new tensor or variable, you can print it in the following line whereas in python, you can only print the tensor or variable only during a session. The get_by_tensor_name does not really have a sense in Js.
As for the predict function, you do have one in Js as well. if you create a model using tf.model or tf.sequential, you can invoke predict to make a prediction.

Get selected values in a checkbox group in xpages

I have a checkbox group and I am trying to get the values ​​selected via SSJS, but so far I have not been successful. I've tried several syntaxes, such as:
document1.getItemValueArray ("nameField")
and
getComponent ("nameField") getSelectedValues ​​();
Does anyone know a way to get the selected values ​​from a checkbox group?
document1.getFirstItem("nameField").getValues() may be what you want. If it's one value, it will be a string, not a Vector, which may be a problem with getItemValueArray().
With ODA (OpenNTF Domino API), we extended the getItemValue() method to take a second parameter and cast the result to that kind of object. That has a big benefit for this kind of scenario, allowing getItemValue("nameField", ArrayList.class) to always return an ArrayList even for a single value, plus ArrayList is a much better and more modern Java (so relevant also for SSJS) construct than a Vector.

Saving a decision tree model for later application in Julia

I have trained a pruned decision tree model in Julia using the DecisionTree module. I now want to save this model for use on other data sets later.
I have tried converting the model to a data array for export using writetable() and I have tried exporting using writedlm() and neither of these work. When I look at the type of the model I see that it is a DecisionTree.Node type. I don't know how to work with this and can't get it to export/save.
In:DataFrame(PrunedModel)
Out:LoadError: MethodError: `convert` has no method matching convert(::Type{DataFrames.DataFrame}, ::DecisionTree.Node)
This may have arisen from a call to the constructor DataFrames.DataFrame(...),
since type constructors fall back to convert methods.
Closest candidates are:
call{T}(::Type{T}, ::Any)
convert(::Type{DataFrames.DataFrame}, !Matched::Array{T,2})
convert(::Type{DataFrames.DataFrame}, !Matched::Dict{K,V})
...
while loading In[22], in expression starting on line 1
in call at essentials.jl:56
In:typeof(PrunedModel)
Out:DecisionTree.Node
Any ideas how I can get this model saved for use later?
If I understand correctly that this is a Julia object, you should try using the JLD.jl package to save the object to disk and load it back in, preserving the type information.

pybrain image input to dataset for Neural Network

I'm trying to write a neural network that (after being properly trained) identifies certain road signs and returns a different output for each type of sign.
Before I started to train my network, I noticed on the pybrain website that their datasets are always an array of values, each entry containing an input and a target. The images I have for my NN have been converted to grayscale pixel data (a simple array of numbers). To train each set of data, do I need to somehow add a target value for each pixel? And if so, how would I go about doing that?
QUICK ANSWER
No, you don't need target for every single pixel, you treat pixels from single image as your input data and you add target to that data.
LONG ANSWER
What you trying to do is to solve classification problem. You have image represented by array of numbers and you need to classify it as some class from limited set of classes.
So lets say that you have 2 classes: prohibitions signs (I'm not native speaker, I don't know how you call signs that forbid something), and information signs. Lets say that prohibition signs is our class 1 and information signs is class 2.
Your data set should look like this:
([representation of sign in numbers], class) - single sample
After that, since it's classification problem, I recommend using _convertToOneOfMany() method of DataSet class, to convert your targets into multiple outputs.
I've answered similar question here, go check it out.

What does AlwaysUsesMultipleValuesMarker do in NSTreeController?

According to Apple's documentation,
setAlwaysUsesMultipleValuesMarker:
Sets whether the receiver always returns the multiple values marker when multiple objects are selected, even if they have the same value.
- (void)setAlwaysUsesMultipleValuesMarker:(BOOL)flag
Discussion:
Setting flag to YES can increase performance if your application doesn’t allow editing multiple values. The default is NO.
However, I have trouble understanding what this all means even after reading the documentation. Can anybody offer a simpler explanation with examples?
Found the answer to this question deep inside apple docs on Cocoa Binding Guide.
NSMultipleValuesMarker
The NSMultipleValuesMarker indicates that more than one object is selected in the controller and the values for the requested key aren’t the same.
By default controllers return the NSMultipleValuesMarker only when the values for the requested key differ. For example, if the value for selection.name returns an array containing three strings—”Tony”, “Tony”, “Tony”—the string “Tony” is returned instead of the NSMultipleValuesMarker.
A collection controller can be configured—either programmatically using the method setAlwaysUsesMultipleValuesMarker: or by checking the Always uses multiple values marker checkbox in Interface Builder—such that it always returns NSMultipleValuesMarker when multiple items are selected, even if the values are equal.

Resources