Python code while building simple neural network
2*np.random.random.((3,1))-1
In the above syntax why we use 2*
at the starting and -1
at the last...
Plz help me by providing a correct relavant answer
python
add a comment |
2*np.random.random.((3,1))-1
In the above syntax why we use 2*
at the starting and -1
at the last...
Plz help me by providing a correct relavant answer
python
1
What is the question you want to be answered?
– Klaus D.
Nov 20 '18 at 2:18
1
Your code is syntactically incorrect.
– DYZ
Nov 20 '18 at 2:36
add a comment |
2*np.random.random.((3,1))-1
In the above syntax why we use 2*
at the starting and -1
at the last...
Plz help me by providing a correct relavant answer
python
2*np.random.random.((3,1))-1
In the above syntax why we use 2*
at the starting and -1
at the last...
Plz help me by providing a correct relavant answer
python
python
edited Nov 20 '18 at 2:17
Klaus D.
7,40911935
7,40911935
asked Nov 20 '18 at 2:15
Amulya KlAmulya Kl
11
11
1
What is the question you want to be answered?
– Klaus D.
Nov 20 '18 at 2:18
1
Your code is syntactically incorrect.
– DYZ
Nov 20 '18 at 2:36
add a comment |
1
What is the question you want to be answered?
– Klaus D.
Nov 20 '18 at 2:18
1
Your code is syntactically incorrect.
– DYZ
Nov 20 '18 at 2:36
1
1
What is the question you want to be answered?
– Klaus D.
Nov 20 '18 at 2:18
What is the question you want to be answered?
– Klaus D.
Nov 20 '18 at 2:18
1
1
Your code is syntactically incorrect.
– DYZ
Nov 20 '18 at 2:36
Your code is syntactically incorrect.
– DYZ
Nov 20 '18 at 2:36
add a comment |
1 Answer
1
active
oldest
votes
From the documentation
Results are from the “continuous uniform” distribution over the stated interval. To sample Unif[a, b), b > a multiply the output of random_sample by (b-a) and add a:
(b - a) * random_sample() + a
In other words, instead of sampling between 0 (included) and 1 (excluded), you sample here from -1 (included) to 1 (excluded). This is just arithmetic on a numpy array.
Giving in more details, the first operation in your line of code is numpy.random.random((3, 1))
. This calls the random() function from the numpy.random library. This function takes one input which is the size of the object you want to generate. Here, you generate a numpy array that has 3 rows and one column. This array is filled with random values between 0 and 1. Then, the second operation is 2 *
. With this, each value of the array is multiplied by 2, so that all values are between 0 and 2. Finally, -1
. Here, 1 is subtracted to all values of the array, so that your final values lie between -1 and 1.
Thaks for ur reply... as I don't have much knowledge on coding can u plz explain more clearly
– Amulya Kl
Nov 20 '18 at 2:46
Please see the update in my answer.
– Patol75
Nov 20 '18 at 2:53
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53385271%2fpython-code-while-building-simple-neural-network%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
From the documentation
Results are from the “continuous uniform” distribution over the stated interval. To sample Unif[a, b), b > a multiply the output of random_sample by (b-a) and add a:
(b - a) * random_sample() + a
In other words, instead of sampling between 0 (included) and 1 (excluded), you sample here from -1 (included) to 1 (excluded). This is just arithmetic on a numpy array.
Giving in more details, the first operation in your line of code is numpy.random.random((3, 1))
. This calls the random() function from the numpy.random library. This function takes one input which is the size of the object you want to generate. Here, you generate a numpy array that has 3 rows and one column. This array is filled with random values between 0 and 1. Then, the second operation is 2 *
. With this, each value of the array is multiplied by 2, so that all values are between 0 and 2. Finally, -1
. Here, 1 is subtracted to all values of the array, so that your final values lie between -1 and 1.
Thaks for ur reply... as I don't have much knowledge on coding can u plz explain more clearly
– Amulya Kl
Nov 20 '18 at 2:46
Please see the update in my answer.
– Patol75
Nov 20 '18 at 2:53
add a comment |
From the documentation
Results are from the “continuous uniform” distribution over the stated interval. To sample Unif[a, b), b > a multiply the output of random_sample by (b-a) and add a:
(b - a) * random_sample() + a
In other words, instead of sampling between 0 (included) and 1 (excluded), you sample here from -1 (included) to 1 (excluded). This is just arithmetic on a numpy array.
Giving in more details, the first operation in your line of code is numpy.random.random((3, 1))
. This calls the random() function from the numpy.random library. This function takes one input which is the size of the object you want to generate. Here, you generate a numpy array that has 3 rows and one column. This array is filled with random values between 0 and 1. Then, the second operation is 2 *
. With this, each value of the array is multiplied by 2, so that all values are between 0 and 2. Finally, -1
. Here, 1 is subtracted to all values of the array, so that your final values lie between -1 and 1.
Thaks for ur reply... as I don't have much knowledge on coding can u plz explain more clearly
– Amulya Kl
Nov 20 '18 at 2:46
Please see the update in my answer.
– Patol75
Nov 20 '18 at 2:53
add a comment |
From the documentation
Results are from the “continuous uniform” distribution over the stated interval. To sample Unif[a, b), b > a multiply the output of random_sample by (b-a) and add a:
(b - a) * random_sample() + a
In other words, instead of sampling between 0 (included) and 1 (excluded), you sample here from -1 (included) to 1 (excluded). This is just arithmetic on a numpy array.
Giving in more details, the first operation in your line of code is numpy.random.random((3, 1))
. This calls the random() function from the numpy.random library. This function takes one input which is the size of the object you want to generate. Here, you generate a numpy array that has 3 rows and one column. This array is filled with random values between 0 and 1. Then, the second operation is 2 *
. With this, each value of the array is multiplied by 2, so that all values are between 0 and 2. Finally, -1
. Here, 1 is subtracted to all values of the array, so that your final values lie between -1 and 1.
From the documentation
Results are from the “continuous uniform” distribution over the stated interval. To sample Unif[a, b), b > a multiply the output of random_sample by (b-a) and add a:
(b - a) * random_sample() + a
In other words, instead of sampling between 0 (included) and 1 (excluded), you sample here from -1 (included) to 1 (excluded). This is just arithmetic on a numpy array.
Giving in more details, the first operation in your line of code is numpy.random.random((3, 1))
. This calls the random() function from the numpy.random library. This function takes one input which is the size of the object you want to generate. Here, you generate a numpy array that has 3 rows and one column. This array is filled with random values between 0 and 1. Then, the second operation is 2 *
. With this, each value of the array is multiplied by 2, so that all values are between 0 and 2. Finally, -1
. Here, 1 is subtracted to all values of the array, so that your final values lie between -1 and 1.
edited Nov 20 '18 at 2:53
answered Nov 20 '18 at 2:19
Patol75Patol75
6236
6236
Thaks for ur reply... as I don't have much knowledge on coding can u plz explain more clearly
– Amulya Kl
Nov 20 '18 at 2:46
Please see the update in my answer.
– Patol75
Nov 20 '18 at 2:53
add a comment |
Thaks for ur reply... as I don't have much knowledge on coding can u plz explain more clearly
– Amulya Kl
Nov 20 '18 at 2:46
Please see the update in my answer.
– Patol75
Nov 20 '18 at 2:53
Thaks for ur reply... as I don't have much knowledge on coding can u plz explain more clearly
– Amulya Kl
Nov 20 '18 at 2:46
Thaks for ur reply... as I don't have much knowledge on coding can u plz explain more clearly
– Amulya Kl
Nov 20 '18 at 2:46
Please see the update in my answer.
– Patol75
Nov 20 '18 at 2:53
Please see the update in my answer.
– Patol75
Nov 20 '18 at 2:53
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53385271%2fpython-code-while-building-simple-neural-network%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
What is the question you want to be answered?
– Klaus D.
Nov 20 '18 at 2:18
1
Your code is syntactically incorrect.
– DYZ
Nov 20 '18 at 2:36