In tensorflow serving, how to store a list in feature dictionary? - tensorflow

I'm pretty new with tensorflow serving, now I'm working with client-end coding.
With the basic tutorial, I know I need to build a feature dictionary like:
feature_dict={
'input_content':tf.train.Feature(...)
'input_label':tf.train.Feature(...)
}
Then,
model_input=tf.train.Example(feature=tf.train.Features(feature=feature_dict))
Now, my question is, how can I put a list into the feature_dict?
Like, I have a 10 dimension list, I want to set it as the 'input_content', how can I get that?

A tf.train.Feature contains lists which may hold zero or more values. The lists could be of type BytesList, FloatList, or Int64List.
The following code adds a single float element (float_element) to the tf.train.Feature
tf.train.Feature(float_list=tf.train.FloatList(value=[float_element]))
Notice that the float_element is surrounded by square brackets ([]), i.e., a list is being created with a single element.
While trying to add a list (float_list), one should not use square brackets like the following code snippet.
tf.train.Feature(float_list=tf.train.FloatList(value=float_list))

Related

Splunk: Entry looks like an array but can't be accessed as one

I've got a portion of a log entry which looks like an array, but I can only access it with the {} notation.
For example, I think the path is line.ul-log-data.meta.data[0].foo, but the only way I can access the value is line.ul-log-data.meta.data{}.foo.
I've been experimenting with various multivalue field evaluations but coming up short. For example, when I do an mvcount("line.ul-log-data.meta.data"), it returns 1.
What do I have to do to use the array notation [0] and get that count to return 2?
Splunk uses curly brackets to access JSON arrays because square brackets have a very different, historical function.
Have you tried mvcount("line.ul-log-data.meta.data{}")?

Confused about Tensorflow Algorithm function

Colab notebook
Under the section on Feature Columns, there is this specific line of code
feature_columns = [ ]
for feature_name in CATEGORICAL_COLUMNS:
vocabulary = dftrain[feature_name].unique()
I'm struggling to understand what this is doing. I don't really know what to search up too as I'm still quite new to programming. Why is there a need for this line? I understand that it outputs all unique values of the specified feature_name, but don't get how it's linked to the next line.
When you don't understand a function just google the module name (TensorFlow) and the function name. I found the documentation for tf.feature_column.categorical_column_with_vocabulary_list described here. To quote the documentation:
Use this when your inputs are in string or integer format, and you have an in-memory vocabulary mapping each value to an integer ID. By default, out-of-vocabulary values are ignored.
What this section of code is doing is going through each column and mapping each unique string value to a unique integer (its location in the vocabulary list). Transforming your column using this type of mapping is common for categorical data. The reason that unique is needed is because tf.feature_column.categorical_column_with_vocabulary_list needs a unique list as an argument before it can work its magic.
In the future please put all necessary code in the question. It should not be required to visit another link to answer your question.

Graphics from arrays in LabVIEW

I have attached a picture of what I have tried.
Starting from an array with values to graph and another array with the names of these values, I would want to graph them all. For later, from the front panel, I want to be able to choose which ones I want to visualize and which not. In the attached image is what I have tried and it does not work only know how to graph the 1 value with the first name but not the others.
The property you need for setting the names is "Active Plot".
The key to writing multiple plots is the "Bundle" node (or "Bundle By Name").
Result:

String Template: is it possible to get the n-th element of a Java List in the template?

In String Template one can easily get an element of a Java Map within the template.
Is it possible to get the n-th element of an array in a similar way?
According to the String Template Cheat Sheet you can easily get the first or second element:
You can combine operations to say things like first(rest(names)) to get second element.
but it doesn't seem possible to get the n-th element easily. I usually transform my list into a map with list indexes as keys and do something like
map.("25")
Is there some easier/more straightforward way?
Sorry, there is no mechanism to get a[i].
There is no easy way getting n-th element of the list.
In my opinion this indicates that your view and business logic are not separated enough: knowledge of what magic number 25 means is spread in both tiers.
One possible solution might be converting list of values to object which provides meaning to the elements. For example, lets say list of String represents address lines, in which case instead of map.("3") you would write address.street.

cacti: Display how much % one data source item has of an other datasource item

I want to create a graph template in which it is displayed how much percentage a data source item has of another data source item.
I assumed I'd need to use CDEF functions for that and according to that question CDEF Function to find % value in Cacti it isn't even a difficult one.
However, I have no idea how to actually use the given CDEF function within the graph template web interface, how to choose which data source items should serve as input for the CDEF function, how to get the CDEF functions output as input for drawing a graph item of (e.g of type LINE1).
Nowhere does the documentation mentions such things, or if, I didn't find or get it.
The way to find out what datasource is what letter value is by going into Console -> Graph Management -> Pick the Graph you are working on -> Turn On Debug Mode
What you are looking for are the lines that start with DEF a=, b= etc.
From there you build the CDEF function using reverse polish notation as shown in my question you have referenced above.
To use the value in a graph eg a LINE add a new item in the graph template then just dont select a datasource and select your prebuilt CDEF function like below.
That should do exactly what you are looking for. In my example I used an AREA but that is just what was best suited for the graph in question.