|
If you are going to post code format it properly by using the pre tags
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Are you going to read this much long code with this kind of formatting if someone provides you ?
Think yourself and decide
your time begins now
Life's Like a mirror. Smile at it & it smiles back at you.- P Pilgrim
So Smile Please
|
|
|
|
|
Its hard to go through your complete program, but it looks like you are running just too many loops (some of them nested).
I would start at looking to refactor some of your logic to avoid running so many loops.
Also try and use break; to get out of the loop once the loop logic is complete.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Are you still stuggling with this !
Please format your code, as you can see it is dificult to read and you are being down voted.
Point one: Nested loops = poor performance [generally].
Your class structure is wrongly IMO. Each Neuron should have a List<Dendrite> for both input and output. A Dendrite should have both an input and output Neuron as well as any weighting. You might need to put deltas in there too, I can't remember. There needs to be a special subclass for the Input Layer and Output layer as these don't have Input Neurons and Output Neurons respectively.
Set the activation inputs, and calculate the activations on each layer in succession. The calculation is easy:
InputAcivation = 0.0;
ForEach(Dendrite dendrite in InputDendrites)
InputAcivation += dendrite.Activation;
Activation = Squash(InputActivation);
Note that I have the Dendrite class calculaing the Activation from the input, "Weight * InputActivation".
The backprop works in a similar way (but reverse!) the desired output is placed onto a property on the output layer, and then each layered is worked back to the input. I really can't remember the ins and outs of this, but you only really need to loop over each neuron in each layer to do this, plus the dendrites.
One advantage of generic Lists over arrays (if you are having a speed problem) is that you can trim "dead" connections (ones whose weights are near zero and have little momentum over multiple tries. Another suggestion is to try to define Halting Criteria, which defines when the NNW is getting it right enough to stop learning. You can over-train a NNW.
One final thing, the OO encapsulation is poor IMO, the calculation code (as I have suggested above) should be in the Neurons, not the main code block. This goes for the backprop calcs too. If you do this, you won't have so many array calls confusing the mix, and you'll be able to profile your app a little better.
[Edit]
My class structure probably isn't the best, I last wrote a NNW ~10 years ago as an undergrad, in c++, but hopefully you'll get the idea. Did you check out the NNW article on CP I mentioned in your previous thread?
|
|
|
|
|
hi, Everybody.
Firstly Thanks for repyl.
i wonder, is there any solution for nested loop in ANN.
can you explain with a example?
My project is about back propagation neural network this project.
to run fast of this project, when i can change my class, will program run fast ?
|
|
|
|
|
Hello,
I am dealing with some problems on using the Wpf advanced text formatting capabilities. I have created my custom TextSource, which loops through custom spans in text lines than contain properties such as offset, length and forecolor. For each span, it creates a TextRun - however, through debugging, I have found out that it creates the TextRuns multiple times for each span, which results in text being shown multiple times.
Have anyone had the same problem? Should I post my code?
Thanks,
Theo
|
|
|
|
|
Theodor Storm Kristensen wrote: Should I post my code?
Yes - but in the WPF forum.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Hi Experts,
Kindly let me know that, How may I use following command using C#?
MD C:\ABC123
Regards
(Riaz)
|
|
|
|
|
Google is your friend:
http://msdn.microsoft.com/en-us/library/as2f1fez.aspx[^]
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
|
Well, MD means Make Directory, so you could always use the equivalent .NET Framework commands:
if (!Directory.Exists(myDirectory))
{
Directory.CreateDirectory(myDirectory);
}
|
|
|
|
|
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
if (p.Start())
{
p.StandardInput.WriteLine("net use " + strFileName + " " + strPwd + " /user:" + strDomain + "\\" + strId);
p.StandardInput.WriteLine("exit");
p.WaitForExit();
string ReturnText = p.StandardOutput.ReadToEnd();
if (ReturnText.IndexOf("成功") >= 0)
Dts.TaskResult = (int)ScriptResults.Success;
else
throw new Exception("fail");
}
else
throw new Exception("fail");
Refrence: http://www.programlive.tk
|
|
|
|
|
I am trying to create an all singing all dancing and very dynamic user control.
On this user control is a button that when you click it opens a new form. The new form populates a list box type with a set of enumeration values and allows the user to make a few selections and then close it.
What I am wondering is how I can pass the list box's selected items back to the user control as a property or something so that the controls parent form can access it. I wanted to avoid passing it back to the root form and keep it all in the user control to keep the API for the thing simple.
I have tried most of the examples where I add properties or 'setting' functions that I then call from the parent user control. I get red lines under things in VS telling me that the property/method is not a member of the 'windows.forms class'... casting problem?
This is how I call it in the user control...
private void bn_show_a_listbox_form_Click(object sender, EventArgs e)
{
Form listbox_form = new listbox_form_Dialog(typeof(enum_for_the_list_box));
listbox_form .Show();
listbox_form .Dispose();
}
Any help would be most welcome.
|
|
|
|
|
You are on the right track - create a property to access the listbox selected items as part of the form, and access them in the click event.
BTW: Don't do this:
JasonD_S wrote: listbox_form .Show();
listbox_form .Dispose();
The Form.Show() method returns immediately - the form will be displayed later. You cannot dispose it yet - it is still in use. I suspect you want to use Form.ShowDialog() instead as that waits for the user to finish with the form before it returns. You can then access the new form property to get the listbox selected items before you dispose the form.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
This I have tried... it's been a while since I last used .Net (have been mostly doing C on Linux recently! ), but I get the error from VS that the list_box_selected_blah is not a property of windows.forms.... it doesn't seem to recognise that the object it one of my own creation. Most odd. Any ideas?
|
|
|
|
|
How are you defining it?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
I know this may seem like a convoluted way of just showing a list box, but there is limited space on screen that is going to be populated by a lot of these users controls so it makes sense to have options displayed in new forms...
Form Text_List = new Text_List_Dialog(typeof(enum_For_The_Text_List));
where
public partial class Text_List_Dialog: Form
{
//Stuff
}
Any clearer?
|
|
|
|
|
No, what I meant was how are you defining the selected items property?
I assume something like:
public partial class Text_List_Dialog: Form
{
...
public List<string> SelectedItems
{
get
{
List<string> items = new List<string>;
for (int i = 0; i < ListBox1.SelectedItems.Count; i++)
{
items.Add(ListBox1.SelectedItems[i].ToString);
}
return items;
}
}
...
} If not, what are you doing?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
You could set make your listbox public, and in your form closing handler, just do something tith form.listBox.SelectedItems .
Of course there are a number of ways to handle this, and this is just one of them.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Visual studio .Net 2008 C#
User toolbar editing example code please....
don't find search in codeproject example code..
|
|
|
|
|
Hi -
I have a piece of C# code that write message log to Database. Now I would like to create unit test scripts using Visual Studio Unit Test framework.
I need to create Unit Test code to verify if the data is written properly to the database or not.
How do I write code or what mechanism I should use to verify this.
Thanks,
Shub
|
|
|
|
|
See here[^].
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Well in my opinion doing a unit test does not involve actually seeing if the data got written properly to the database. That is an integration test in my opinion. Unit tests should just test that module and nothing else. I would make a mock database adaptor and have the test make sure all the proper commands where made to the adaptor from your code. To me this is a truer unit test.
Leon Lambert
|
|
|
|
|
You have two choices.
First choice is actually write the data to the Database, ideally within a transation so that it can be rolled back. You need to be able to run your Unit Tests repeatedly without leaving a mess behind.
Second Choice is to Mock the Database. If you haven't designed your app from the start with this in mind then it can be tricky to retrofit.
If you need more info on Mocking just ask.
-Rd
Hit any user to continue.
|
|
|
|
|
Ok, I've been working on a user control that basically houses a FlowLayoutPanel control and allows you to add PictureBox Controls through code. The adding part works, however the code that removes the PictureBox's only seems to remove the ones that are visible.
This is the code that removes the controls:
public void RemovePictures()
{
foreach (Control pic in flpPanel.Controls)
{
pic.Click -= PictureClicked;
flpPanel.Controls.Remove(pic);
pic.Dispose();
}
}
flpPanel is a FlowLayoutPanel as I stated above.
Am I doing something wrong, is this a bug? I am using Visual C# Express 2010 and building in .Net Framework 4.0
Update:
A look at the Methods supported by the ControlsCollection class i see a Clear() method. (I should have guessed considering its a collection) Anyway, I'm worried about using this rather than what was above as Clear() does not give me the ability to unhook the event from each picture box...
Anyone have an idea of whether this is a bad thing?
modified on Thursday, October 7, 2010 10:34 PM
|
|
|
|