I'm developing uTensor and the code generator for it, utensor_cgen.
https://github.com/uTensor/uTensor
https://github.com/uTensor/utensor_cgen
For the code generator, I have to parse a quantized graph_def protocolbuff file (the pb file).
However, I found that there are some input node not visible in tensorboard but visible in the graph_def.node.
Their name starts with a ^ and when I look into tf.import_graph_def source code, I found this _IsControlInput function:
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/framework/importer.py#L92
I really need to know the definition of "control input" so I can properly parse the pb file and convert it into a correct uTensor implementation targeting MCU.
Can somebody tell me where I can find the definition?
It seems like not found in the documentation.
Thanks.
It might be related to control dependencies. https://www.tensorflow.org/api_docs/python/tf/Graph#control_dependencies
Related
So I am learning Python through Udemy tutorials and now I need to open a file through CMD(CMD is opened on folder I need) and when I am typing function for opening file it says syntax error, but I have made everything good what a guy on tutorials says, I really don't know what what should I do, I checked all of the forums and still cant find the answer.
Here are some screenshots:
Couple of issues:
1.Your text file is called "example.txt.txt" instead of "example.txt"
2.The "example.txt","r" should be surrounded with brackets () instead of <>. These symbols look similar in cmd and are easy to confuse.
#instead of
file = open<"example.txt","r">
#use
file = open("example.txt","r")
This should fix your problem; let me know if it does.
You have to use parenthesss () not <>
file = open("example.txt","r")
check https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files
Is there some library available to write a ~/.pypirc file programmatically?
Also, what is the formal spec of its format? All I've found is this section of the docs:
https://docs.python.org/3.3/distutils/packageindex.html#pypirc
That leaves out details like what kinds of whitespace are allowable, whether = and : are equivalent or not, and so on.
The file is read by distutils/config.py using RawConfigParser.
So if you want to write it use the same RawConfigParser. The docs you pointed are the only docs. The rest could be deduced from the code.
When I use this code,it will automatically creates a file.Why?Where can I see the source code of this function?
with open('E:/test.txt','w') as f:
for i in range(10):
f.write('abc\n')
f.close()
The w flag opens a file, truncates it, and then begins writing from the beginning. I was interested in investigating why it creates files as soon as you call it, but there doesn't seem to be much in the spec that describes it's anticipated behavior.
While it mightn't be easy to find the source code, you can see the documentation here. See the table under the modes argument for an explanation of all the modes you can use.
We can only guess as to the intentions of the people who wrote open(), but it would seem that the one thing consistent among all modes is:
Open file and return a corresponding file object. If the file cannot be opened, an OSError is raised.
Without getting input from whoever wrote the spec I would assume they consider "open file" to involve creating it if it doesn't exist.
This is actually a very good question, you got me thinking. Since Python is open-source, one should be able to see more than the documentation, the actual code! I utilized this thread and finally got to the source code. This sort of built-in functions are usually implemented in C. So if you know C -I don't!- you will be able to read through it and understand fully.
Here is the source code:
https://github.com/python/cpython/blob/master/Modules/_io/fileio.c
(Check out the full directory to make sense of it:
https://github.com/python/cpython/tree/master/Modules/_io)
Search the term 'w' (with the single quotes) and go from there.
It contains code like this, which is what you are looking for:
case 'r':
if (rwa)
goto bad_mode;
rwa = 1;
self->readable = 1;
break;
case 'w':
if (rwa)
goto bad_mode;
rwa = 1;
self->writable = 1;
flags |= O_CREAT | O_TRUNC;
break;
So I'm thinking this is one of those problems where I can't see the forest for the tree. Here is the assignment:
Using the file object input, write code that read an integer from a file called
rawdata into a variable datum (make sure you assign an integer value to datum).
Open the file at the beginning of your code, and close it at the end.
okay so first thing: I thought the input function was for assigning data to an object such as a variable, not for reading data from an object. Wouldn't that be read.file_name ?
But I gave it shot:
infile = open('rawdata','r')
datum = int(input.infile())
infile.close()
Now first problem... MyProgrammingLab doesn't want to grade it. By that I mean I type in the code, click 'submit' and I get the "Checking" screen. And that's it. At the time of writing this, my latest attempt to submit as been 'checking' for 11 minutes. It's not giving me an error, it's just not... 'checking' I guess.
Now at the moment I can't use Python to try the program because it's looking for a while and I'm on a school computer that is write locked, so even if I have the code right (I doubt it), the program will fail to run because it can neither find the file rawdata nor create it.
So... what's the deal? Am I reading the instructions wrong or is it telling me to use input in some other way then I'm trying to use it? Or am I supposed to be using a different method?
You are so close. You're just using the file object slightly incorrectly. Once it's open, you can just .read() it, and get the value.
It would probably look something like this
infile = open('rawdata','r')
datum = int(infile.read())
infile.close()
I feel like your confusion is based purely on the wording of the question - the term "file object input" can certainly be confusing if you haven't worked with Python I/O before. In this case, the "file object" is infile and the "input" would be the rawdata file, I suppose.
Currently taking this class and figured this out. This is my contribution to all of us college peeps just trying to make it through, lol. MPL accepts this answer.
input = open('rawdata','r')
datum = int(input.readline())
input.close()
I'm importing an mp3 file using IPython (more specifically, the IPython.display.display(IPython.display.Audio() command) and I wanted to know if there was a specific way you were supposed to format the file path.
The documentation says it takes the file path so I assumed (perhaps incorrectly) that it should be something like \home\downloads\randomfile.mp3 which I used an online converter to convert into unicode. I put that in (using, of course, filename=u'unicode here' but that didn't work, instead giving a bunch of errors. I tried reformatting it in different ways (just \downloads\randomfile.mp3, etc) but none of them worked. For those who are curious, here is the unicode characters: \u005c\u0044\u006f\u0077\u006e\u006c\u006f\u0061\u0064\u0073\u005c\u0062\u0064\u0061\u0079\u0069\u006e\u0073\u0074\u0072\u0075\u006d\u0065\u006e\u0074\u002e\u006d\u0070\u0033 which translates to \home\Downloads\bdayinstrument.mp3, I believe.
So, am I doing something wrong? What is the correct way to format the "file path"?
Thanks!