Quansight-Labs / numpy.net

A port of NumPy to .Net
BSD 3-Clause "New" or "Revised" License
137 stars 15 forks source link

No random functions #3

Closed QadiymStewart closed 4 years ago

QadiymStewart commented 4 years ago

np.random.randn not found

np.random.uniform not found

are these function implemented as of yet?

QadiymStewart commented 4 years ago

Seems like randn isn't producing any negative values compared to NumSharp's random_normal function

NumpyDotnet image

NumSharp image

KevinBaselinesw commented 4 years ago

Let me know if you got them.

From: Qadiym Stewart notifications@github.com Sent: Thursday, March 5, 2020 9:53 PM To: Quansight-Labs/numpy.net numpy.net@noreply.github.com Cc: KevinBaselinesw kmckenna@baselinesw.com; State change state_change@noreply.github.com Subject: Re: [Quansight-Labs/numpy.net] No random functions (#3)

I don't see any screenshots. You can email them to me qadiym.stewart@live.ca mailto:qadiym.stewart@live.ca

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/Quansight-Labs/numpy.net/issues/3?email_source=notifications&email_token=ACP4GWSVLXHVMGAMYDYAO7TRGBQP7A5CNFSM4KTW4HOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEN73RHI#issuecomment-595572893 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ACP4GWRR2YWV4RZ3532DG4DRGBQP7ANCNFSM4KTW4HOA . https://github.com/notifications/beacon/ACP4GWSOJ2G54OC5QMQVYFTRGBQP7A5CNFSM4KTW4HOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEN73RHI.gif

QadiymStewart commented 4 years ago

Got the screenshots now

KevinBaselinesw commented 4 years ago

I think I implemented that function correctly per the docs.

Use the standard_normal function I added in a recent release instead.

From: Qadiym Stewart notifications@github.com Sent: Thursday, March 5, 2020 9:58 PM To: Quansight-Labs/numpy.net numpy.net@noreply.github.com Cc: KevinBaselinesw kmckenna@baselinesw.com; State change state_change@noreply.github.com Subject: Re: [Quansight-Labs/numpy.net] No random functions (#3)

Seems like randn isn't producing any negative values compared to NumSharp's random_normal function

NumpyDotnet https://user-images.githubusercontent.com/28968495/76045680-d6312980-5f2b-11ea-825c-3de25222e11b.png

NumSharp https://user-images.githubusercontent.com/28968495/76045872-55bef880-5f2c-11ea-94bb-a67c45788d9c.png

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/Quansight-Labs/numpy.net/issues/3?email_source=notifications&email_token=ACP4GWWENLUUETTK7TGKQRDRGBRCRA5CNFSM4KTW4HOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEN7335Y#issuecomment-595574263 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ACP4GWUQBL5GICQKF4WMUP3RGBRCRANCNFSM4KTW4HOA . https://github.com/notifications/beacon/ACP4GWSGWWRE3SMM6775APTRGBRCRA5CNFSM4KTW4HOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEN7335Y.gif

QadiymStewart commented 4 years ago

numsh numpy

All good now getting expected values. it was the RANDN switched to the new standard_normal

QadiymStewart commented 4 years ago

Thanks for all the help.

KevinBaselinesw commented 4 years ago

You are very welcome.

Thanks for sticking with me and helping me debug my tool. Let me know if you have any other problems.

Time for bed.

From: Qadiym Stewart notifications@github.com Sent: Thursday, March 5, 2020 10:14 PM To: Quansight-Labs/numpy.net numpy.net@noreply.github.com Cc: KevinBaselinesw kmckenna@baselinesw.com; State change state_change@noreply.github.com Subject: Re: [Quansight-Labs/numpy.net] No random functions (#3)

Thanks for all the help.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/Quansight-Labs/numpy.net/issues/3?email_source=notifications&email_token=ACP4GWTIVWGSJSJGKDFJQXLRGBTBHA5CNFSM4KTW4HOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEN744UI#issuecomment-595578449 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ACP4GWUDGJWW4WYO4CGVCJLRGBTBHANCNFSM4KTW4HOA . https://github.com/notifications/beacon/ACP4GWVE6GVOW2M5Y5FBRKTRGBTBHA5CNFSM4KTW4HOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEN744UI.gif

QadiymStewart commented 4 years ago

Saved me 7 seconds generating larger images (1500px) nice :) 👍

KevinBaselinesw commented 4 years ago

That is great!!

Remember I also had to remove some of my earlier performance improvements because of the miscalculations.

Assuming I can get those back in (without breaking it) it should go much faster still.

From: Qadiym Stewart notifications@github.com Sent: Friday, March 6, 2020 1:45 AM To: Quansight-Labs/numpy.net numpy.net@noreply.github.com Cc: KevinBaselinesw kmckenna@baselinesw.com; State change state_change@noreply.github.com Subject: Re: [Quansight-Labs/numpy.net] No random functions (#3)

Saved me 7 seconds generating larger images (1500px) nice :) 👍

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/Quansight-Labs/numpy.net/issues/3?email_source=notifications&email_token=ACP4GWV2QD5LFESMOCP4EH3RGCLX5A5CNFSM4KTW4HOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOAILZI#issuecomment-595625445 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ACP4GWUMHYD45QXHOM56FHDRGCLX5ANCNFSM4KTW4HOA . https://github.com/notifications/beacon/ACP4GWWWIP635AGFUSNQ7V3RGCLX5A5CNFSM4KTW4HOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOAILZI.gif

QadiymStewart commented 4 years ago

Anyway to make random thread-safe? Running into an issue where if I do a parallel for loop with a seed different images are being produced. In a standard for loop everything is fine.

Task.Run(() => Parallel.For(0, 4, i => { GenerateImageNumpyDotNet($"numpyimageParallel{i}", size, size, seed: seed, vec: vector); }));

KevinBaselinesw commented 4 years ago

Great question!! The answer is yes if you can wait a few days.

I actually got the original numpy random number generator replicated. That means I can produce the EXACT bit stream of random numbers given the same seed.

With that, I have been able to go through and port all of the random number generators. I am now working my through the various “distributions” that Numpy provides. I am writing unit tests to verify the generated output against what python produces.

Once I have that, I will be converting it to an instantiable class, each with it’s own random number generator which means that each thread can instantiate it’s own random object without interfering with any other threads.

From: Qadiym Stewart notifications@github.com Sent: Wednesday, March 11, 2020 1:51 PM To: Quansight-Labs/numpy.net numpy.net@noreply.github.com Cc: KevinBaselinesw kmckenna@baselinesw.com; State change state_change@noreply.github.com Subject: Re: [Quansight-Labs/numpy.net] No random functions (#3)

Anyway to make random thread-safe? Running into an issue where if I do a parallel for loop with a seed different images are being produced. In a standard for loop everything is fine.

Task.Run(() => Parallel.For(0, 4, i => { GenerateImageNumpyDotNet($"numpyimageParallel{i}", size, size, seed: seed, vec: vector); }));

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/Quansight-Labs/numpy.net/issues/3#issuecomment-597777000 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ACP4GWVRCJBORYMWWPVODALRG7FP5ANCNFSM4KTW4HOA . https://github.com/notifications/beacon/ACP4GWQQKYRAHBEOBP654SDRG7FP5A5CNFSM4KTW4HOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOQVU2A.gif

QadiymStewart commented 4 years ago

Alright I'll wait for the next release. Thanks for the quick response.

KevinBaselinesw commented 4 years ago

Next release is out there. I also sent you a direct email.

From: Qadiym Stewart notifications@github.com Sent: Wednesday, March 11, 2020 2:12 PM To: Quansight-Labs/numpy.net numpy.net@noreply.github.com Cc: KevinBaselinesw kmckenna@baselinesw.com; State change state_change@noreply.github.com Subject: Re: [Quansight-Labs/numpy.net] No random functions (#3)

Alright I'll wait for the next release. Thanks for the quick response.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/Quansight-Labs/numpy.net/issues/3#issuecomment-597787357 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ACP4GWTN2P7WA7UES2RBSD3RG7H53ANCNFSM4KTW4HOA . https://github.com/notifications/beacon/ACP4GWV2YUUIXYJPMY5AMYLRG7H53A5CNFSM4KTW4HOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOQYFXI.gif

QadiymStewart commented 4 years ago

Thanks for the update. Seems a bit faster great job. After testing out the new update, I don’t see expected results from the parallel for loop. The standard for loop works as expected but when I convert to parallel it’s generating 4 different images. If you console log the output for “vector”, standard FOR loop gives same result but parallel FOR loop gives all different(I don’t think it’s respecting the seed). (It gives same value each time I rerun the program but expected results should be same values provided a seed.... correct ?!?! Am I missing something ? Provided repo link below.)

  public ndarray Generate(int width = 256, int height = 256, float scaling = 20.0f, ndarray z = null)
    {
        //Generate Random Key to generate image
        var vector = z;
        if (vector == null)
        {
            vector = random.uniform(-1, 1, new shape(BatchSize, HSize)).astype(np.Float32);
        }

        var data = CreateGrid(width, height, scaling);
        return BuildCPPN(width, height, data[0], data[1], data[2], vector);
    }

Repo Can be found here https://twinnaz.visualstudio.com/_git/CSHARPCPPN

KevinBaselinesw commented 4 years ago

Fixed the problems. Sent you and email at:

in*@v**linc.com mailto:info@vieralinc.com

From: Qadiym Stewart notifications@github.com Sent: Thursday, March 12, 2020 11:51 PM To: Quansight-Labs/numpy.net numpy.net@noreply.github.com Cc: KevinBaselinesw kmckenna@baselinesw.com; State change state_change@noreply.github.com Subject: Re: [Quansight-Labs/numpy.net] No random functions (#3)

Reopened #3 https://github.com/Quansight-Labs/numpy.net/issues/3 .

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/Quansight-Labs/numpy.net/issues/3#event-3125299389 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ACP4GWSKPX37YX6R6FSJ4IDRHGUTJANCNFSM4KTW4HOA . https://github.com/notifications/beacon/ACP4GWS3X2CT7JACH53IWSLRHGUTJA5CNFSM4KTW4HOKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOXJEERPI.gif

QadiymStewart commented 4 years ago

Fixed :)