How to use CPPFlow with giving a .txt as input - c++

I recently used cppflow on VS 2019 on Windows 10.
My original data is data in 4 columns per row. I want to use neural network to classify precipitation particles. I have trained and saved my model (.pb) on python. Because it is text data in .txt, and the example described in the cppflow document uses pictures as input, I would like to ask what is the function of cppflow input in .txt text?

Read the .txt file into a std::vector then convert into a cppflow::tensor.

Related

Problem with reading data from '-v7.3' mat file using C++

I tried to read the .mat file with -v7.3 in C++. As the .mat file with version -7.3 is the same as the hdf5 file, I try to read the mat file with the hdf5 API. I able to open group, reference, and the dataset. I also able to read the dataset with struct, int, double, or character array format.
But I see one dataset show its name as a class type. But I don't know how I read it. I attached an image for better understanding.
"error" field shows the value of a class type name. When I open it in matlab it shows like the below picture -
I also try a compound data type to read it. But I can not able to read. Can you suggest me any way to read the data from -v7.3 mat file in C++?

How can i manipulate csv's from within c++

I am trying to create a program that can read out to a csv (comma separated). Is there a way to manipulate say the column width or whether a cell is left or right justified internally from my code so that when i open up the file in excel it looks better than a bunch of strings cramped into tiny cells. My goal is for the user to do as little thinking as possible. If they open up the file and have to size everything right just to see it that seems a little crummy.
CSV is a plain text file format. It doesn't support any visual formatting. For that, you need to write the data to another file format such as .xlsx or .ods.

save Large RasterBrick to file for later use

I have a Large RasterBrick, created through compiling a large number of .nc files and then manipulating in a few ways (cropping, collapsing, naming layers). I want to save this brick to a file on my laptop, so that I can access it without having to import all data and manipulate anew.
How do I do this? I think it should involve writeRaster, but I'm not sure how to specify the options.
My RasterBrick is 18 by 25, with 14975 layers, each named with the relevant date.
I tried this code from Save multi layer RasterBrick to harddisk:
outfile <- writeRaster(windstack_mn, filename='dailywindgrid.tif', format="GTiff", overwrite=TRUE,options=c("INTERLEAVE=BAND","COMPRESS=LZW"))
However, this code produce a tif file that holds a single 18 by 25 layer. I think it saved only the 1st layer of my RasterBrick, because if I bring in the saved .tif file and plot it, it looks identical to plotting the 1st layer of the original RasterBrick.
Did you look at outfile? Can you show it to us?
You should show what you do to "bring in the saved .tif". I am guessing that you do
raster('dailywindgrid.tif')
whereas you should be doing
brick('dailywindgrid.tif')
The comment/answer fr/ Robert solves my issue, with the one addition that one needs to specify the raster format. So I am now saving the file with this code:
writeRaster(StackName, filename='FileNAme.grd', format="raster", overwrite=TRUE,options=c("INTERLEAVE=BAND","COMPRESS=LZW"))
And that .grd file can later be opened using this code:
ImportName <- brick("FileNAme.grd")

how to create & encode a label file using sample images for tensorflow

we are trying to detect special characters like + and - inside an image using tensorflow by extending the MNIST sample code -> https://github.com/opensourcesblog/tensorflow-mnist
We have also been able to create a binary encoded file using our sample images needed for training the neural network by using the sample code -> https://github.com/jkarnows/idx-formatter
But we are not finding a way how to create a label file for our images and then to create a binary encoded label file using the label file
Both of these files are very important for proceeding further .
Anybody having any idea is most welcome to share them with us
The data is in gzip format, decoded with extract_labels, each label on 8 bytes. You can use numpy.getbuffer to convert a uint8 array back.
Alternatively, you can just create your own extract_labels which reads labels in whatever format you see fit.

Using OpenCV's KNearest Neighbour - OpenCV; C++

I'm want to use OpenCV's KNN algorithm to classify 4 features into one of two classes. In a text file, I have my training data in the following format:
feature_1,feature_2,feature_3,feature_4,class
where feature_1, feature_3, feature_4 and class are integers and feature_2 is of type float. The first line of the text file contains the headings for each feature.
However, the OpenCV documentation (http://docs.opencv.org/modules/ml/doc/k_nearest_neighbors.html) states that the train function requires the training data in the Mat data structure.
I'm confused as to how I can convert my text file of training data, to a Mat. If anyone can help me out with this I would really appreciate it.
Basicly, OpenCV implements CvMLData which can read csv files (and your file is a comma separated file).
according to documentation: http://docs.opencv.org/modules/ml/doc/mldata.html
Once you create an CvMLData object, you can use read_csv method:
read_csv(const char* filename)
to load it, and then use get_values() to get pointer to the input data as Mat and get_responses() to get the pointer to the labels as Mat
To set which column is considered as "response" (label) use the set_response_idx method