Same process outputs different numpy arrays
I've got a script that turns songs into numpy arrays (librosa
library), pickles them to db and later extracts.
I'm storing arrays in SQLite like it's shown there
So my script parses 4 different folders with rap, rock, pop and electro songs, 100~ files each. The same function is used for every folder:
def insert(self, genre, data):
conn = sqlite3.connect(DATABASE_FILE,
detect_types=sqlite3.PARSE_DECLTYPES)
curs = conn.cursor()
curs.execute(f"""insert into {genre} values(?)""", (data,))
conn.commit()
conn.close()
But when I output these arrays, they all look different. Rap and pop are shown one way (the way I need) and rock and electro the other one. Example:
The way I don't need:
[[[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 ... 2.54755225e-02
1.35376751e-01 -7.20393434e-02]]
[[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 ... -2.36755103e-01
-1.50851190e-01 -1.60914958e-01]]
[[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 ... -9.19092745e-02
-7.79412016e-02 -5.93096465e-02]]
...
The way I need:
[[array([-1.3420450e-05, -1.2423131e-05, -1.5018032e-05, ...,
-3.0817756e-01, -2.4027914e-01, -2.3190670e-01], dtype=float32)]
[array([ 0. , 0. , 0. , ..., -0.7026442 ,
-0.67226726, -0.7215703 ], dtype=float32)]
[array([0. , 0. , 0. , ..., 0.06976765, 0.22147852,
0.11491765], dtype=float32)]
[array([0. , 0. , 0. , ..., 0.22524872, 0.1910718 ,
0.2159081 ], dtype=float32)]
My extract method:
def execute(self, genre):
conn = sqlite3.connect(DATABASE_FILE,
detect_types=sqlite3.PARSE_DECLTYPES)
curs = conn.cursor()
curs.execute(f'''select arr from {genre}''')
data = curs.fetchall()
conn.close()
return data
So my question is how is this possible? The order of outputs is: good, bad, good, bad
What's wrong?
P.S. the key difference is shown while running .size method:
130
110139750
130
172651500
Even though the size must be around 100. Built-in len() function in this case works as expected.
python numpy
add a comment |
I've got a script that turns songs into numpy arrays (librosa
library), pickles them to db and later extracts.
I'm storing arrays in SQLite like it's shown there
So my script parses 4 different folders with rap, rock, pop and electro songs, 100~ files each. The same function is used for every folder:
def insert(self, genre, data):
conn = sqlite3.connect(DATABASE_FILE,
detect_types=sqlite3.PARSE_DECLTYPES)
curs = conn.cursor()
curs.execute(f"""insert into {genre} values(?)""", (data,))
conn.commit()
conn.close()
But when I output these arrays, they all look different. Rap and pop are shown one way (the way I need) and rock and electro the other one. Example:
The way I don't need:
[[[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 ... 2.54755225e-02
1.35376751e-01 -7.20393434e-02]]
[[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 ... -2.36755103e-01
-1.50851190e-01 -1.60914958e-01]]
[[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 ... -9.19092745e-02
-7.79412016e-02 -5.93096465e-02]]
...
The way I need:
[[array([-1.3420450e-05, -1.2423131e-05, -1.5018032e-05, ...,
-3.0817756e-01, -2.4027914e-01, -2.3190670e-01], dtype=float32)]
[array([ 0. , 0. , 0. , ..., -0.7026442 ,
-0.67226726, -0.7215703 ], dtype=float32)]
[array([0. , 0. , 0. , ..., 0.06976765, 0.22147852,
0.11491765], dtype=float32)]
[array([0. , 0. , 0. , ..., 0.22524872, 0.1910718 ,
0.2159081 ], dtype=float32)]
My extract method:
def execute(self, genre):
conn = sqlite3.connect(DATABASE_FILE,
detect_types=sqlite3.PARSE_DECLTYPES)
curs = conn.cursor()
curs.execute(f'''select arr from {genre}''')
data = curs.fetchall()
conn.close()
return data
So my question is how is this possible? The order of outputs is: good, bad, good, bad
What's wrong?
P.S. the key difference is shown while running .size method:
130
110139750
130
172651500
Even though the size must be around 100. Built-in len() function in this case works as expected.
python numpy
add a comment |
I've got a script that turns songs into numpy arrays (librosa
library), pickles them to db and later extracts.
I'm storing arrays in SQLite like it's shown there
So my script parses 4 different folders with rap, rock, pop and electro songs, 100~ files each. The same function is used for every folder:
def insert(self, genre, data):
conn = sqlite3.connect(DATABASE_FILE,
detect_types=sqlite3.PARSE_DECLTYPES)
curs = conn.cursor()
curs.execute(f"""insert into {genre} values(?)""", (data,))
conn.commit()
conn.close()
But when I output these arrays, they all look different. Rap and pop are shown one way (the way I need) and rock and electro the other one. Example:
The way I don't need:
[[[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 ... 2.54755225e-02
1.35376751e-01 -7.20393434e-02]]
[[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 ... -2.36755103e-01
-1.50851190e-01 -1.60914958e-01]]
[[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 ... -9.19092745e-02
-7.79412016e-02 -5.93096465e-02]]
...
The way I need:
[[array([-1.3420450e-05, -1.2423131e-05, -1.5018032e-05, ...,
-3.0817756e-01, -2.4027914e-01, -2.3190670e-01], dtype=float32)]
[array([ 0. , 0. , 0. , ..., -0.7026442 ,
-0.67226726, -0.7215703 ], dtype=float32)]
[array([0. , 0. , 0. , ..., 0.06976765, 0.22147852,
0.11491765], dtype=float32)]
[array([0. , 0. , 0. , ..., 0.22524872, 0.1910718 ,
0.2159081 ], dtype=float32)]
My extract method:
def execute(self, genre):
conn = sqlite3.connect(DATABASE_FILE,
detect_types=sqlite3.PARSE_DECLTYPES)
curs = conn.cursor()
curs.execute(f'''select arr from {genre}''')
data = curs.fetchall()
conn.close()
return data
So my question is how is this possible? The order of outputs is: good, bad, good, bad
What's wrong?
P.S. the key difference is shown while running .size method:
130
110139750
130
172651500
Even though the size must be around 100. Built-in len() function in this case works as expected.
python numpy
I've got a script that turns songs into numpy arrays (librosa
library), pickles them to db and later extracts.
I'm storing arrays in SQLite like it's shown there
So my script parses 4 different folders with rap, rock, pop and electro songs, 100~ files each. The same function is used for every folder:
def insert(self, genre, data):
conn = sqlite3.connect(DATABASE_FILE,
detect_types=sqlite3.PARSE_DECLTYPES)
curs = conn.cursor()
curs.execute(f"""insert into {genre} values(?)""", (data,))
conn.commit()
conn.close()
But when I output these arrays, they all look different. Rap and pop are shown one way (the way I need) and rock and electro the other one. Example:
The way I don't need:
[[[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 ... 2.54755225e-02
1.35376751e-01 -7.20393434e-02]]
[[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 ... -2.36755103e-01
-1.50851190e-01 -1.60914958e-01]]
[[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 ... -9.19092745e-02
-7.79412016e-02 -5.93096465e-02]]
...
The way I need:
[[array([-1.3420450e-05, -1.2423131e-05, -1.5018032e-05, ...,
-3.0817756e-01, -2.4027914e-01, -2.3190670e-01], dtype=float32)]
[array([ 0. , 0. , 0. , ..., -0.7026442 ,
-0.67226726, -0.7215703 ], dtype=float32)]
[array([0. , 0. , 0. , ..., 0.06976765, 0.22147852,
0.11491765], dtype=float32)]
[array([0. , 0. , 0. , ..., 0.22524872, 0.1910718 ,
0.2159081 ], dtype=float32)]
My extract method:
def execute(self, genre):
conn = sqlite3.connect(DATABASE_FILE,
detect_types=sqlite3.PARSE_DECLTYPES)
curs = conn.cursor()
curs.execute(f'''select arr from {genre}''')
data = curs.fetchall()
conn.close()
return data
So my question is how is this possible? The order of outputs is: good, bad, good, bad
What's wrong?
P.S. the key difference is shown while running .size method:
130
110139750
130
172651500
Even though the size must be around 100. Built-in len() function in this case works as expected.
python numpy
python numpy
asked Dec 27 '18 at 15:53
Desiigner
1568
1568
add a comment |
add a comment |
active
oldest
votes
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%2f53947632%2fsame-process-outputs-different-numpy-arrays%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f53947632%2fsame-process-outputs-different-numpy-arrays%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