Weird data type error using tensorflow and numpy
I don't understand the difference betwen the two codes here below:
Is there a reason why this works:
def evaluer_dessin ():
global result,img
listeimage=
for y in matrice:
for x in y:
listeimage.append(x)
img = np.array([listeimage])
afficher_resultat()
try:
Cadre.delete(result)
except:
pass
if evaluerimg:
result=Cadre.create_text(Largeur/2,Hauteur/8,text="c'est un
"+str((prediction[0]+1)%10),font=('', '50'),fill="red")
root.after(300,evaluer_dessin)
def afficher_resultat():
global prediction
prediction = session.run(y_pred_cls,feed_dict={ x : img})
But this code here doesn't :
def evaluer_dessin ():
global result
listeimage=
for y in matrice:
for x in y:
listeimage.append(x)
img = np.array([listeimage])
# this is the line that doesn't work, it says that it cant convert an
# int into a tensor
prediction = session.run(y_pred_cls,feed_dict={ x : img})
try:
Cadre.delete(result)
except:
pass
if evaluerimg:
result=Cadre.create_text(Largeur/2,Hauteur/8,text="c'est un
"+str((prediction[0]+1)%10),font=('', '50'),fill="red")
root.after(300,evaluer_dessin)
It says that "img" is an int but it's type is clearly an array, and the weirdest thing is that when I use a seperate function to calculate the prediction, it works well!
Here's the error shown for the second program:
>Traceback (most recent call last):
> File "C:UsersnicolAppDataLocalProgramsPythonPython35libsite-packagestensorflowpythonclientsession.py", line 1092, in _run
> subfeed, allow_tensor=True, allow_operation=False)
> File "C:UsersnicolAppDataLocalProgramsPythonPython35libsite-packagestensorflowpythonframeworkops.py", line 3490, in as_graph_element
> return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
> File "C:UsersnicolAppDataLocalProgramsPythonPython35libsite-packagestensorflowpythonframeworkops.py", line 3579, in >_as_graph_element_locked
> types_str))
>TypeError: Can not convert a int into a Tensor.
>
>During handling of the above exception, another exception occurred:
>
>Traceback (most recent call last):
> File "C:UsersnicolDesktopCNN_exeprogrammeCNNexe.py", line 170, in <module>
> evaluer_dessin()
> File "C:UsersnicolDesktopCNN_exeprogrammeCNNexe.py", line 123, in >evaluer_dessin
> prediction = session.run(y_pred_cls,feed_dict={ x : img})
> File "C:UsersnicolAppDataLocalProgramsPythonPython35libsite-packagestensorflowpythonclientsession.py", line 929, in run
> run_metadata_ptr)
> File "C:UsersnicolAppDataLocalProgramsPythonPython35libsite-packagestensorflowpythonclientsession.py", line 1095, in _run
> 'Cannot interpret feed_dict key as Tensor: ' + e.args[0])
>TypeError: Cannot interpret feed_dict key as Tensor: Can not convert a int into >a Tensor.
>[Finished in 2.1s with exit code 1]
>[shell_cmd: python -u "C:UsersnicolDesktopCNN_exeprogrammeCNNexe.py"]
>[dir: C:UsersnicolDesktopCNN_exe]
>[path: C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS >Client;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSyst>em32WindowsPowerShellv1.0;C:Program Files (x86)IntelIntel(R) Management >Engine ComponentsDAL;C:Program FilesIntelIntel(R) Management Engine >ComponentsDAL;C:Program Files (x86)IntelIntel(R) Management Engine ComponentsIPT;C:Program FilesIntelIntel(R) Management Engine ComponentsIPT;C:Program FilesIntelWiFibin;C:Program FilesCommon FilesIntelWirelessCommon;C:WINDOWSSystem32OpenSSH;C:UsersnicolAppData>LocalProgramsPythonPython35Scripts;C:UsersnicolAppDataLocalPrograms>PythonPython35;C:UsersnicolAppDataLocalProgramsPythonPython37Scripts>;C:UsersnicolAppDataLocalProgramsPythonPython37;C:UsersnicolAppData>LocalMicrosoftWindowsApps;]
python tensorflow tensor
add a comment |
I don't understand the difference betwen the two codes here below:
Is there a reason why this works:
def evaluer_dessin ():
global result,img
listeimage=
for y in matrice:
for x in y:
listeimage.append(x)
img = np.array([listeimage])
afficher_resultat()
try:
Cadre.delete(result)
except:
pass
if evaluerimg:
result=Cadre.create_text(Largeur/2,Hauteur/8,text="c'est un
"+str((prediction[0]+1)%10),font=('', '50'),fill="red")
root.after(300,evaluer_dessin)
def afficher_resultat():
global prediction
prediction = session.run(y_pred_cls,feed_dict={ x : img})
But this code here doesn't :
def evaluer_dessin ():
global result
listeimage=
for y in matrice:
for x in y:
listeimage.append(x)
img = np.array([listeimage])
# this is the line that doesn't work, it says that it cant convert an
# int into a tensor
prediction = session.run(y_pred_cls,feed_dict={ x : img})
try:
Cadre.delete(result)
except:
pass
if evaluerimg:
result=Cadre.create_text(Largeur/2,Hauteur/8,text="c'est un
"+str((prediction[0]+1)%10),font=('', '50'),fill="red")
root.after(300,evaluer_dessin)
It says that "img" is an int but it's type is clearly an array, and the weirdest thing is that when I use a seperate function to calculate the prediction, it works well!
Here's the error shown for the second program:
>Traceback (most recent call last):
> File "C:UsersnicolAppDataLocalProgramsPythonPython35libsite-packagestensorflowpythonclientsession.py", line 1092, in _run
> subfeed, allow_tensor=True, allow_operation=False)
> File "C:UsersnicolAppDataLocalProgramsPythonPython35libsite-packagestensorflowpythonframeworkops.py", line 3490, in as_graph_element
> return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
> File "C:UsersnicolAppDataLocalProgramsPythonPython35libsite-packagestensorflowpythonframeworkops.py", line 3579, in >_as_graph_element_locked
> types_str))
>TypeError: Can not convert a int into a Tensor.
>
>During handling of the above exception, another exception occurred:
>
>Traceback (most recent call last):
> File "C:UsersnicolDesktopCNN_exeprogrammeCNNexe.py", line 170, in <module>
> evaluer_dessin()
> File "C:UsersnicolDesktopCNN_exeprogrammeCNNexe.py", line 123, in >evaluer_dessin
> prediction = session.run(y_pred_cls,feed_dict={ x : img})
> File "C:UsersnicolAppDataLocalProgramsPythonPython35libsite-packagestensorflowpythonclientsession.py", line 929, in run
> run_metadata_ptr)
> File "C:UsersnicolAppDataLocalProgramsPythonPython35libsite-packagestensorflowpythonclientsession.py", line 1095, in _run
> 'Cannot interpret feed_dict key as Tensor: ' + e.args[0])
>TypeError: Cannot interpret feed_dict key as Tensor: Can not convert a int into >a Tensor.
>[Finished in 2.1s with exit code 1]
>[shell_cmd: python -u "C:UsersnicolDesktopCNN_exeprogrammeCNNexe.py"]
>[dir: C:UsersnicolDesktopCNN_exe]
>[path: C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS >Client;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSyst>em32WindowsPowerShellv1.0;C:Program Files (x86)IntelIntel(R) Management >Engine ComponentsDAL;C:Program FilesIntelIntel(R) Management Engine >ComponentsDAL;C:Program Files (x86)IntelIntel(R) Management Engine ComponentsIPT;C:Program FilesIntelIntel(R) Management Engine ComponentsIPT;C:Program FilesIntelWiFibin;C:Program FilesCommon FilesIntelWirelessCommon;C:WINDOWSSystem32OpenSSH;C:UsersnicolAppData>LocalProgramsPythonPython35Scripts;C:UsersnicolAppDataLocalPrograms>PythonPython35;C:UsersnicolAppDataLocalProgramsPythonPython37Scripts>;C:UsersnicolAppDataLocalProgramsPythonPython37;C:UsersnicolAppData>LocalMicrosoftWindowsApps;]
python tensorflow tensor
Interesting question - would you mind including the full error message (including a stacktrace if you get any) into the question? (just press "edit" and you can add it)
– Per Lundberg
Nov 18 '18 at 21:33
1
The problem is not withimg
, but withx
. Inafficher_resultat
seems to be a global variable, and inevaluer_dessin
it comes from the global variablematrice
(from the loop), so it is hard to tell when or why it should work or not, but in any case it seems it is not a tensor from the graph, but a plain integer value.
– jdehesa
Nov 20 '18 at 16:56
add a comment |
I don't understand the difference betwen the two codes here below:
Is there a reason why this works:
def evaluer_dessin ():
global result,img
listeimage=
for y in matrice:
for x in y:
listeimage.append(x)
img = np.array([listeimage])
afficher_resultat()
try:
Cadre.delete(result)
except:
pass
if evaluerimg:
result=Cadre.create_text(Largeur/2,Hauteur/8,text="c'est un
"+str((prediction[0]+1)%10),font=('', '50'),fill="red")
root.after(300,evaluer_dessin)
def afficher_resultat():
global prediction
prediction = session.run(y_pred_cls,feed_dict={ x : img})
But this code here doesn't :
def evaluer_dessin ():
global result
listeimage=
for y in matrice:
for x in y:
listeimage.append(x)
img = np.array([listeimage])
# this is the line that doesn't work, it says that it cant convert an
# int into a tensor
prediction = session.run(y_pred_cls,feed_dict={ x : img})
try:
Cadre.delete(result)
except:
pass
if evaluerimg:
result=Cadre.create_text(Largeur/2,Hauteur/8,text="c'est un
"+str((prediction[0]+1)%10),font=('', '50'),fill="red")
root.after(300,evaluer_dessin)
It says that "img" is an int but it's type is clearly an array, and the weirdest thing is that when I use a seperate function to calculate the prediction, it works well!
Here's the error shown for the second program:
>Traceback (most recent call last):
> File "C:UsersnicolAppDataLocalProgramsPythonPython35libsite-packagestensorflowpythonclientsession.py", line 1092, in _run
> subfeed, allow_tensor=True, allow_operation=False)
> File "C:UsersnicolAppDataLocalProgramsPythonPython35libsite-packagestensorflowpythonframeworkops.py", line 3490, in as_graph_element
> return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
> File "C:UsersnicolAppDataLocalProgramsPythonPython35libsite-packagestensorflowpythonframeworkops.py", line 3579, in >_as_graph_element_locked
> types_str))
>TypeError: Can not convert a int into a Tensor.
>
>During handling of the above exception, another exception occurred:
>
>Traceback (most recent call last):
> File "C:UsersnicolDesktopCNN_exeprogrammeCNNexe.py", line 170, in <module>
> evaluer_dessin()
> File "C:UsersnicolDesktopCNN_exeprogrammeCNNexe.py", line 123, in >evaluer_dessin
> prediction = session.run(y_pred_cls,feed_dict={ x : img})
> File "C:UsersnicolAppDataLocalProgramsPythonPython35libsite-packagestensorflowpythonclientsession.py", line 929, in run
> run_metadata_ptr)
> File "C:UsersnicolAppDataLocalProgramsPythonPython35libsite-packagestensorflowpythonclientsession.py", line 1095, in _run
> 'Cannot interpret feed_dict key as Tensor: ' + e.args[0])
>TypeError: Cannot interpret feed_dict key as Tensor: Can not convert a int into >a Tensor.
>[Finished in 2.1s with exit code 1]
>[shell_cmd: python -u "C:UsersnicolDesktopCNN_exeprogrammeCNNexe.py"]
>[dir: C:UsersnicolDesktopCNN_exe]
>[path: C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS >Client;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSyst>em32WindowsPowerShellv1.0;C:Program Files (x86)IntelIntel(R) Management >Engine ComponentsDAL;C:Program FilesIntelIntel(R) Management Engine >ComponentsDAL;C:Program Files (x86)IntelIntel(R) Management Engine ComponentsIPT;C:Program FilesIntelIntel(R) Management Engine ComponentsIPT;C:Program FilesIntelWiFibin;C:Program FilesCommon FilesIntelWirelessCommon;C:WINDOWSSystem32OpenSSH;C:UsersnicolAppData>LocalProgramsPythonPython35Scripts;C:UsersnicolAppDataLocalPrograms>PythonPython35;C:UsersnicolAppDataLocalProgramsPythonPython37Scripts>;C:UsersnicolAppDataLocalProgramsPythonPython37;C:UsersnicolAppData>LocalMicrosoftWindowsApps;]
python tensorflow tensor
I don't understand the difference betwen the two codes here below:
Is there a reason why this works:
def evaluer_dessin ():
global result,img
listeimage=
for y in matrice:
for x in y:
listeimage.append(x)
img = np.array([listeimage])
afficher_resultat()
try:
Cadre.delete(result)
except:
pass
if evaluerimg:
result=Cadre.create_text(Largeur/2,Hauteur/8,text="c'est un
"+str((prediction[0]+1)%10),font=('', '50'),fill="red")
root.after(300,evaluer_dessin)
def afficher_resultat():
global prediction
prediction = session.run(y_pred_cls,feed_dict={ x : img})
But this code here doesn't :
def evaluer_dessin ():
global result
listeimage=
for y in matrice:
for x in y:
listeimage.append(x)
img = np.array([listeimage])
# this is the line that doesn't work, it says that it cant convert an
# int into a tensor
prediction = session.run(y_pred_cls,feed_dict={ x : img})
try:
Cadre.delete(result)
except:
pass
if evaluerimg:
result=Cadre.create_text(Largeur/2,Hauteur/8,text="c'est un
"+str((prediction[0]+1)%10),font=('', '50'),fill="red")
root.after(300,evaluer_dessin)
It says that "img" is an int but it's type is clearly an array, and the weirdest thing is that when I use a seperate function to calculate the prediction, it works well!
Here's the error shown for the second program:
>Traceback (most recent call last):
> File "C:UsersnicolAppDataLocalProgramsPythonPython35libsite-packagestensorflowpythonclientsession.py", line 1092, in _run
> subfeed, allow_tensor=True, allow_operation=False)
> File "C:UsersnicolAppDataLocalProgramsPythonPython35libsite-packagestensorflowpythonframeworkops.py", line 3490, in as_graph_element
> return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
> File "C:UsersnicolAppDataLocalProgramsPythonPython35libsite-packagestensorflowpythonframeworkops.py", line 3579, in >_as_graph_element_locked
> types_str))
>TypeError: Can not convert a int into a Tensor.
>
>During handling of the above exception, another exception occurred:
>
>Traceback (most recent call last):
> File "C:UsersnicolDesktopCNN_exeprogrammeCNNexe.py", line 170, in <module>
> evaluer_dessin()
> File "C:UsersnicolDesktopCNN_exeprogrammeCNNexe.py", line 123, in >evaluer_dessin
> prediction = session.run(y_pred_cls,feed_dict={ x : img})
> File "C:UsersnicolAppDataLocalProgramsPythonPython35libsite-packagestensorflowpythonclientsession.py", line 929, in run
> run_metadata_ptr)
> File "C:UsersnicolAppDataLocalProgramsPythonPython35libsite-packagestensorflowpythonclientsession.py", line 1095, in _run
> 'Cannot interpret feed_dict key as Tensor: ' + e.args[0])
>TypeError: Cannot interpret feed_dict key as Tensor: Can not convert a int into >a Tensor.
>[Finished in 2.1s with exit code 1]
>[shell_cmd: python -u "C:UsersnicolDesktopCNN_exeprogrammeCNNexe.py"]
>[dir: C:UsersnicolDesktopCNN_exe]
>[path: C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS >Client;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSyst>em32WindowsPowerShellv1.0;C:Program Files (x86)IntelIntel(R) Management >Engine ComponentsDAL;C:Program FilesIntelIntel(R) Management Engine >ComponentsDAL;C:Program Files (x86)IntelIntel(R) Management Engine ComponentsIPT;C:Program FilesIntelIntel(R) Management Engine ComponentsIPT;C:Program FilesIntelWiFibin;C:Program FilesCommon FilesIntelWirelessCommon;C:WINDOWSSystem32OpenSSH;C:UsersnicolAppData>LocalProgramsPythonPython35Scripts;C:UsersnicolAppDataLocalPrograms>PythonPython35;C:UsersnicolAppDataLocalProgramsPythonPython37Scripts>;C:UsersnicolAppDataLocalProgramsPythonPython37;C:UsersnicolAppData>LocalMicrosoftWindowsApps;]
python tensorflow tensor
python tensorflow tensor
edited Dec 31 '18 at 8:03
Cœur
17.5k9104145
17.5k9104145
asked Nov 18 '18 at 20:07
Nicolas SchmidNicolas Schmid
95
95
Interesting question - would you mind including the full error message (including a stacktrace if you get any) into the question? (just press "edit" and you can add it)
– Per Lundberg
Nov 18 '18 at 21:33
1
The problem is not withimg
, but withx
. Inafficher_resultat
seems to be a global variable, and inevaluer_dessin
it comes from the global variablematrice
(from the loop), so it is hard to tell when or why it should work or not, but in any case it seems it is not a tensor from the graph, but a plain integer value.
– jdehesa
Nov 20 '18 at 16:56
add a comment |
Interesting question - would you mind including the full error message (including a stacktrace if you get any) into the question? (just press "edit" and you can add it)
– Per Lundberg
Nov 18 '18 at 21:33
1
The problem is not withimg
, but withx
. Inafficher_resultat
seems to be a global variable, and inevaluer_dessin
it comes from the global variablematrice
(from the loop), so it is hard to tell when or why it should work or not, but in any case it seems it is not a tensor from the graph, but a plain integer value.
– jdehesa
Nov 20 '18 at 16:56
Interesting question - would you mind including the full error message (including a stacktrace if you get any) into the question? (just press "edit" and you can add it)
– Per Lundberg
Nov 18 '18 at 21:33
Interesting question - would you mind including the full error message (including a stacktrace if you get any) into the question? (just press "edit" and you can add it)
– Per Lundberg
Nov 18 '18 at 21:33
1
1
The problem is not with
img
, but with x
. In afficher_resultat
seems to be a global variable, and in evaluer_dessin
it comes from the global variable matrice
(from the loop), so it is hard to tell when or why it should work or not, but in any case it seems it is not a tensor from the graph, but a plain integer value.– jdehesa
Nov 20 '18 at 16:56
The problem is not with
img
, but with x
. In afficher_resultat
seems to be a global variable, and in evaluer_dessin
it comes from the global variable matrice
(from the loop), so it is hard to tell when or why it should work or not, but in any case it seems it is not a tensor from the graph, but a plain integer value.– jdehesa
Nov 20 '18 at 16:56
add a comment |
1 Answer
1
active
oldest
votes
Thanks jdehesa for helping me solving the problem. The problem came actually from the variable x and not form img.
All I had to do was to give another name to the the variable in the for loop:
def evaluer_dessin ():
global listeimage,result,img
listeimage=
for y in matrice:
for z in y: # I just change the name from "x" to "z" and the problem was solved
listeimage.append(z)
img = np.array([listeimage])
prediction = session.run(y_pred_cls,feed_dict={ x : img})
try:
Cadre.delete(result)
except:
pass
if evaluerimg:
result=Cadre.create_text(Largeur/2,Hauteur/8,text="c'est un "+str((prediction[0]+1)%10),font=('', '50'),fill="red")
root.after(300,evaluer_dessin)
I'm new to stackoverflow and I just wanted to say how awesome this website is, you get all the answers you want by clever and nice people.
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%2f53364952%2fweird-data-type-error-using-tensorflow-and-numpy%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
Thanks jdehesa for helping me solving the problem. The problem came actually from the variable x and not form img.
All I had to do was to give another name to the the variable in the for loop:
def evaluer_dessin ():
global listeimage,result,img
listeimage=
for y in matrice:
for z in y: # I just change the name from "x" to "z" and the problem was solved
listeimage.append(z)
img = np.array([listeimage])
prediction = session.run(y_pred_cls,feed_dict={ x : img})
try:
Cadre.delete(result)
except:
pass
if evaluerimg:
result=Cadre.create_text(Largeur/2,Hauteur/8,text="c'est un "+str((prediction[0]+1)%10),font=('', '50'),fill="red")
root.after(300,evaluer_dessin)
I'm new to stackoverflow and I just wanted to say how awesome this website is, you get all the answers you want by clever and nice people.
add a comment |
Thanks jdehesa for helping me solving the problem. The problem came actually from the variable x and not form img.
All I had to do was to give another name to the the variable in the for loop:
def evaluer_dessin ():
global listeimage,result,img
listeimage=
for y in matrice:
for z in y: # I just change the name from "x" to "z" and the problem was solved
listeimage.append(z)
img = np.array([listeimage])
prediction = session.run(y_pred_cls,feed_dict={ x : img})
try:
Cadre.delete(result)
except:
pass
if evaluerimg:
result=Cadre.create_text(Largeur/2,Hauteur/8,text="c'est un "+str((prediction[0]+1)%10),font=('', '50'),fill="red")
root.after(300,evaluer_dessin)
I'm new to stackoverflow and I just wanted to say how awesome this website is, you get all the answers you want by clever and nice people.
add a comment |
Thanks jdehesa for helping me solving the problem. The problem came actually from the variable x and not form img.
All I had to do was to give another name to the the variable in the for loop:
def evaluer_dessin ():
global listeimage,result,img
listeimage=
for y in matrice:
for z in y: # I just change the name from "x" to "z" and the problem was solved
listeimage.append(z)
img = np.array([listeimage])
prediction = session.run(y_pred_cls,feed_dict={ x : img})
try:
Cadre.delete(result)
except:
pass
if evaluerimg:
result=Cadre.create_text(Largeur/2,Hauteur/8,text="c'est un "+str((prediction[0]+1)%10),font=('', '50'),fill="red")
root.after(300,evaluer_dessin)
I'm new to stackoverflow and I just wanted to say how awesome this website is, you get all the answers you want by clever and nice people.
Thanks jdehesa for helping me solving the problem. The problem came actually from the variable x and not form img.
All I had to do was to give another name to the the variable in the for loop:
def evaluer_dessin ():
global listeimage,result,img
listeimage=
for y in matrice:
for z in y: # I just change the name from "x" to "z" and the problem was solved
listeimage.append(z)
img = np.array([listeimage])
prediction = session.run(y_pred_cls,feed_dict={ x : img})
try:
Cadre.delete(result)
except:
pass
if evaluerimg:
result=Cadre.create_text(Largeur/2,Hauteur/8,text="c'est un "+str((prediction[0]+1)%10),font=('', '50'),fill="red")
root.after(300,evaluer_dessin)
I'm new to stackoverflow and I just wanted to say how awesome this website is, you get all the answers you want by clever and nice people.
edited Nov 21 '18 at 18:01
answered Nov 21 '18 at 17:55
Nicolas SchmidNicolas Schmid
95
95
add a comment |
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%2f53364952%2fweird-data-type-error-using-tensorflow-and-numpy%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
Interesting question - would you mind including the full error message (including a stacktrace if you get any) into the question? (just press "edit" and you can add it)
– Per Lundberg
Nov 18 '18 at 21:33
1
The problem is not with
img
, but withx
. Inafficher_resultat
seems to be a global variable, and inevaluer_dessin
it comes from the global variablematrice
(from the loop), so it is hard to tell when or why it should work or not, but in any case it seems it is not a tensor from the graph, but a plain integer value.– jdehesa
Nov 20 '18 at 16:56