When we create the .rec file, do the class ids in the .lst file have to be consecutive and start from 0? - mxnet

If all the images come from 3 classes, can the set of class ids we put into the second column of the .lst file be {101, 280, 76}? Or it has to be consecutive integers like {5,6,7}, or even more strict, has to be {0,1,2} ?
Thanks.

There are no requirements on label values. For your case, {101, 280, 76} should be fine.

Related

Stata: How to use column value as file name in loop

I am working with 350 datasets. I want to automate naming the final datasets with values from the dataset.
For example, if ID is abc and year is 2010. There are two columns in the dataset with those values. I want to pull that information out and use in the file name. and the name would look like abc_2010.dta in this case.
So basically I want to do
foreach file in `files' {
**calculation codes**
** construct the file name as three digit ID_year.dta **
}
I have already done the calculation part. I need some help with the naming of the files.
If I understand what you are trying to do, I believe you should be able to do this:
foreach file in `files' {
**calculation codes**
** construct the file name as three digit ID_year.dta **
local fname:di "`=id[1]'_`=year[1]'"
save `fname', replace
}
Note that this assume that after the calculation of the current iteration of the loop through files, the value of id in the first row holds the three digit code and the value of year in the first row holds the year.

ABAP Report Logic

I am new to ABAP.
I have a requirement in abap.In my presentation server ,there is header text file, which I want to upload data from that text file to Header table. But the custom table is having different structure from text file.
It includes extra 4 fields- PO_CREATED_DATE, PO_CREATED_BY, PO_CHANGED_DATE, PO_CHANGED_BY.
These fields have to populate from our report program using sy-datum and sy-uname.
In this scenario,we have to check,If the data is existing then populate
PO_CHANGED_DATE, PO_CHANGED_BY and if the data is not there,then populate PO_CREATED_DATE, PO_CREATED_BY.
Please let me know the logic...
first load the file into an internal table with only 1 very long field (long enough to contain at least the longest possible line in the file). Then loop over that itab and split the individual lines using the separator that is used in the file. You split the contents into a work area that contains all your fields, including the 4 extra fields that may or may not be included in the file. Make sure to clear the work area before splitting the line into the WA. Append the work area to an itab with the same structure as the wa, then continue with the next line.
After that, loop over that second itab and check for lines where your 4 extra fields are initial. Those are the lines where you need to add the data by code. After that, do whatever you need to do with the data in the itab.
I uploaded text file header data to it_input1 using gui_upload.But the it_input1 is not having extra 4 fields.I declared another itable it_header which is having the same structure as Header custom table.Now i wnt to check whether the data in the it_input 1 is alredy existing or not.If existing ,populate it_header-po_changed_date and it_header-po_changed_by or else, it_header-po_created_date and it_header-po_created_by.
Take a look to the "Pattern" Button on top. Select ABAP Objects an press enter.
Now you can supply the class and methdo you want to call.
CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
GUI_UPLOAD is a static method. If you are new that is the easiest way to see which parameters must be supplied. With the forward navigation (double-click) you can check the signature for typing the parameter variables.
Then you just need to convert your data (e.g. SPLIT). I can only recommend to use the F1-Help.
Kind regards!

CHCSVParsing an unusual csv file

I'm having difficulties as to how I should parse this kind of csv file.
For example:
06:16 PM,7,299,http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0026_heavy_rain_showers_night.png,Moderate rain at times,14,22,180,S,3.1,81,10,993,75
2014-01-31,9,48,3,38,22,35,176,S,119,http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0003_white_cloud.png,Cloudy,6.0
2014-02-01,7,45,3,37,19,30,220,SW,113,http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0001_sunny.png,Sunny,2.2
2014-02-02,9,47,3,37,17,27,236,SW,113,http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0001_sunny.png,Sunny,0.0
2014-02-03,8,46,3,37,21,34,152,SSE,116,http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0002_sunny_intervals.png,Partly Cloudy,1.8
2014-02-04,9,48,3,38,20,32,191,SSW,263,http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0009_light_rain_showers.png,Patchy light drizzle,1.4
"London","United Kingdom","City Of London, Greater London",51.517,-0.106,7421228,http://www.worldweatheronline.com/London-weather/City-of-London-Greater-London/GB.aspx
For example, I need to get the first two values on the first line, all the values on the 2nd to 6th line, and the first value of the 7th line.
I currently have a model class with properties for all the values I need to get.
I'm not sure how to do it in this situation. So far, I know how to parse that csv (if I didn't need to get the first two values on the 1st line, and the first value of the 7th line)
What would be the logic to parse in this situation? Hope you guys can give me some idea how to do it.
Thanks
Split the string into lines (busing a scanner or array method depending on how big the string is). Once you have your lines, takes the special ones and pass to appropriate methods to extract the required values. Likewise for the main lines.
You can use your parser on each line individually or use a scanner or array method if that's easier depending on what content you need to extract and where it is.

Comparing NSString to NSTextView Range prior to Appending

Coding in Objective-C, I'm appending text to a NSTextView object named subCap in my code like so:
[[[_subCAP textStorage] mutableString]appendString:[NSString stringWithFormat:#"%#", subcapLine]];
subcapLine will have two timecode values such as: "01:00:00:00 01:00:01:00" separated by a single space, then a newline (\n) character, then a string like "ONC314_001_001" followed by two newline chars (\n\n).
The end result will create a list similar to:
01:00:00:00 01:00:01:00
ONC314_001_001
01:00:01:00 01:00:02:00
ONC314_001_002
01:00:02:00 01:00:03:00
ONC314_001_003
etc, etc, etc.
It's a sub caption file for placing text (the ONC314 lines) at appropriate times in a video file, as indicated by the timecodes.
However, I've determined that there is an odd set of circumstances where a timecode pair could be the same as the previous timecode pair, and if that happens, I want to skip appending that line.
So, my question is, given that the timecodes are always 11 chars apiece, separated by a space, can anybody think of a way I can easily grab the prior TC pair and compare it to my current pair in the subcapLine I'm preparing to append? The problem is the text of the sub caption could be random lengths. In my example they're the same, but that isn't always the case.
If I need to check prior to compiling my subcapLine, I can do that too, but I just thought it might be more slick to use a range of some sort to grab the prior pair of TCs from the last-written line in the NSTextView object and compare (again, using a range?) against the TCs in the line I'm about to append?
Thoughts and suggestions much appreciated.
Chris Conlee
When you add a timecode store the length of the text field string just before you add the timecode so you will have the offset to the timecode you are about to add.
Then before adding a new timecode you could simply use the previous offset you stored to extract the substring and do a string comparison and see if the timecodes are identical.
This should allow you to always have an offset to the previous timecode regardless of the length of the subtitles.

JMeter CSV Dataset Config: how to move through variables in the same thread?

I'm using a CSV dataset config element, which is reading from a file like this:
abd
sds
ase
sdd
ssd
cvv
Which, basically, has a number of 3 letter random string.
I'm assigning them to a variable called ${random_3}.
Now, I want to use values from this list multiple times within the same thread, but each time I want to move to next. For example, I want the first sampler to use abd, the 2nd to use sds, then ase, etc. But if I just use ${random_3} then only the first one (abd) is used wherever it's referred to. Is there a way I can specify to loop through the values from the CSV dataset within a thread?
CSV Data Set Config works fine for this. All of the values need to be in one column in the file and assign them to the variable as described.
Create a Thread Group that has as many threads for as many users as you want iterating over the file (i.e. acting on the HTTP Request). Assuming 1 user, set the number of threads to 1, loop count to 1.
Inside the thread group you will need to add a Loop Controller or a While Controller. You indicated that you want to loop through the whole data set. If you add a loop controller you will want to set the Loop Count to 6, since you have 6 values, one for each value. Alternately (and easier for processing the whole file) add a While Controller instead of a Loop Controller and set ${random_3} as the while condition.
It is important to set the CSV Data Set Recycle on EOF and Stop Thread on EOF values correctly. If you plan to iterate over the file more than once you must set "Recycle on EOF" to True (i.e. instruct jMeter to move back to the top of the CSV file). Set "Stop Thread on EOF" to False if you are using a loop controller, true if you are using a while controller and want to stop after reading the whole csv dataset.
Add the CSV Data Set Config as a child of the controller along with the HTTP Request. View the results using any listener you want to use.
CSV data set moves through file only when each thread iteration starts.
You can use Raw Data Source PreProcessor to move throuhg file with each request, that's your solution.
Note that you need to have the values for a given variable name in the same column.
Doing: abd sds ase sdd ssd cvv is very different from
abd
sds
ase
sdd
ssd
cvv
The first has 6 variables with one value each; the second has one variable with 6 values.
Update:
CSV Dataset does not seem to be a suitable too for this purpose.
I ended up creating some simple beanshell scripts that create a random 1, 2, or 3 letter word as needed, and also another one that reads a random words from a large set. This way, each time they are called they give a random value. They are called like this:
${__BeanShell(getRandomStr(3))}
or
${__BeanShell(getRandomWord())