We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Neural Nettwork (ANN) Extension
#91
You don't need to convert to binary - there are reasons why it may be more efficient for very large data sets, but not probably in SB.

If you are interested in binary representation of numbers (how they are actually stored internally), then this is a fun site which shows why the binary representation of 1 includes 3F as one of its bytes.  If not, then just use ascii and ignore the binary file option.

https://binaryconvert.com/result_double....ecimal=049

PS, if you don't convert to the binary format, them make sure you train with the binary flag "False" and pass in the ascii text file name, NeuralNetwork.ConvertFile(trainingDataText,trainingDataText,"False")
Reply
#92
LitDev,

3f hex is a question mark!

LitDev sad: PS, if you don't convert to the binary format, them make sure you train with the binary flag "False" and pass in the ascii text file name, NeuralNetwork.ConvertFile(trainingDataText,trainingDataText,"False")

Also changing trainingdatabinary to trainingdatatext doesn't work. You get training set file doesn't exist. It needs that binary file even if it doesn't do anything.

JR
Reply
#93
3F is ? in ascii, but each number is stored as 8 bytes - this is just one of them - see the link I shared and read about binary representation of type 'double'.

It will work without the binary file when you only use the ascii file and don't pass the binary file name to the training, DWQZ710.000 - no use of any binary file.
Reply
#94
LitDev.

Could you explain the following ILSpy for Binary Output? Why did the creator put the Value parameter in the second argument? Why do we fill it with 0? It looks like what ever we put in get's copied to Value and then to return if it is not get which I assume is false. As you can tell this has me really confused.

I was wondering if it would be better to have a different ANN extension that isn't so confusing? It seems like the creator put in a lot of stuff that isn't really necessary.

JR



















IlSpy:

// SmallBasicANN.NeuralNetwork
/// <summary>
/// Get or set wether the data is binary "True" or not.
/// </summary>
/// <param name="Name">The ANN name.</param>
/// <param name="Value">The requested data.</param>
/// <param name="Get">"True" to get the requested data.</param>
/// <returns>An error message or the requested data.</returns>
public static Primitive BinaryOutput(Primitive Name, Primitive Value, Primitive Get)
{
    ANN aNN;
    if (!NeuralNetwork.dictionaryANN.TryGetValue(Name, out aNN))
    {
        return "Error: a neural network with that name doesn't exist";
    }
    if (!Get)
    {
        aNN.BinaryOutput = Value;
    }
    return aNN.BinaryOutput;
}
Reply
#95
JR,

This is just setting or getting a variable used by the extension.  In many cases properties are just set or get with an = in Small Basic, for example: GraphicsWindow.BackgroundColor, this can be set with:

GraphicsWindow.BackgroundColor  = "Red"

Or we can get the value with:

colour = GraphicsWindow.BackgroundColor

However, in this case the property also needs to pass in an argument "Name" to identify the ANN to set the property for and we use a method with arguments for this.  And to determine if the value is to be set or not, there is a flag argument called "Get".  Since a method function can return a value, it always returns the current value (seems reasonable).  This may be a bit confusing, but seems logical enough to me?

Perhaps, your question is more to do with the implementation code reported by ILSpy in C# you highlight in your question, or perhaps to do with the use of NeuralNetwork.BinaryOutput method, or maybe just the intellisense (which I added since there was none with the original extension dll).

But for its use, it is just a property used by one of potentially several ANNs, with arguments identifying the ANN, the value to set (if we are setting), a flag to say if we are getting or setting the value, and the return is always the current value.  I suppose we could have 2 functions, one for set and one for get, but its not obvious to me that is easier to understand.
[-] The following 1 user Likes litdev's post:
  • jrmrhrb00
Reply
#96
litDev,

Here's a snippet:

name="XorANN"
'where=program.Directory
'textwindow.writeline(where)
Data=NeuralNetwork.Load("c:\temp\"+name+".txt")
Data=NeuralNetwork.BinaryOutput("c:\temp\"+name+".txt",0,"False")
TextWindow.WriteLine(Data)

If I comment out the second line for data, TextWindow.Writeline prints the first data with the correct name. So, that means it did find the ANN. If I uncomment the second line, textwindow.writeline says "Error a neural network with that name doesn't exist.

I don't understand why that would be! As it just found it. Your thoughts?

ILspy just shows this:

// SmallBasicANN.NeuralNetwork
/// <summary>
/// Get or set wether the data is binary "True" or not.
/// </summary>
/// <param name="Name">The ANN name.</param>
/// <param name="Value">The requested data.</param>
/// <param name="Get">"True" to get the requested data.</param>
/// <returns>An error message or the requested data.</returns>
public static Primitive BinaryOutput(Primitive Name, Primitive Value, Primitive Get)
{
    ANN aNN;
    if (!NeuralNetwork.dictionaryANN.TryGetValue(Name, out aNN))
    {
        return "Error: a neural network with that name doesn't exist";
    }
    if (!Get)
    {
        aNN.BinaryOutput = Value;
    }
    return aNN.BinaryOutput;
}

JR
Reply
#97
JR,

Please try the following 3 lines: no need for any other code.

Code:
name="XorANN"
ANNname = NeuralNetwork.Load("c:\temp\"+name+".txt") 'Return the ANN name, this is its name (identifying label)
Data=NeuralNetwork.BinaryOutput(ANNname,0,"False")
TextWindow.WriteLine(Data)

The load method takes a file path and returns the name of the ANN that was originally used to create it (before it was saved to a file).  If you open the file in a text editor you will see the first line defines the ANN name.  It is the ANN name, not the path that is input to the BinaryOutput and other methods.

EDIT

Corrected code to set variable name as JR mentions below.
[-] The following 1 user Likes litdev's post:
  • jrmrhrb00
Reply
#98
LitDev,

This did work after I added "name" to the top of the code because that was neuralnetwork.load needed. I didn't realize that neuralnetwork.binary output only wanted the real name of the ANN.

Bailed me out again. Thank You!

JR

LitDev,

On occasion, I might come up with a question that is 10 pages back on a thread. Could be a question about an import that is on that page. Is there a way to make a post for that page so that the person that gets the post will know what it is in reference too?

Seems like a lot of times I'm behind in the thread and the current page is concerning something else.

JR
Reply
#99
I guess either

  1. Sart a new thread with a new question
  2. Quote (copy to your post) the content of the thread you refer to
  3. Copy a link to the post you want to refer to in your post
[-] The following 1 user Likes litdev's post:
  • jrmrhrb00
Reply
LitDev,

I like the idea of a link. So, I should be able to goto the pfe in question, make a reply, and include the link.

JR
Reply


Forum Jump:


Users browsing this thread: 14 Guest(s)