I am using TensorFlow 1.7 with Python 3.6.5 on a Mac with High Sierra.
I have trained my first MNIST model, so I basically have
a graph.pbtxt file with the CNN graph structure
some model.ckpt-21000 files (.meta, .index .data)
I tried to freeze the graph using the command line freeze_graph command on my bash:
freeze_graph
--input_graph=/…/graph.pbtxt
--input_checkpoint=/…/model.ckpt-21000
--input_binary=false
--output_graph=/…/frozen_mnist.pb
--output_node_names=softmax_tensor
But I got this error:
Traceback (most recent call last):
File “/usr/local/bin/freeze_graph”, line 11, in <module>
sys.exit(main())
TypeError: main() missing 1 required positional argument: ‘unused_args’
I am not really sure what I am missing there.
I am quite sure I am using the correct syntax.
I have found a workaround to freeze my graph.
I am posting it here so if anyone encounters the same issue, they can use this.
Instead of
freeze_graph
--input_graph=/…/graph.pbtxt
--input_checkpoint=/…/model.ckpt-21000
--input_binary=false
--output_graph=/…/frozen_mnist.pb
--output_node_names=softmax_tensor
Use
python3 -m tensorflow.python.tools.freeze_graph
--input_graph=/…/graph.pbtxt
--input_checkpoint=/…/model.ckpt-21000
--input_binary=false
--output_graph=/…/frozen_mnist.pb
--output_node_names=softmax_tensor
So basically instead of the command freeze_graph I just used python3 -m tensorflow.python.tools.freeze_graph.
Still I would really like to understand why the command line did not work for me :(
Related
I will try to be as much help as I can, but this is certainly a bit out of my depth.
I am trying to run the metagenomics package 'DeepVirFinder' on my fasta file 'my_seqs.fa' within terminal on my Mac. I have followed the GitHub repository instructions (as found here https://github.com/jessieren/DeepVirFinder). I have created a conda environment with all the necessary packages.
Into my terminal I have inputted
python dvf.py -i ~/Documents/PairwiseANI/my_seqs.fna -o ~/Documents/DeepVirFinder/ -l 1000 -c 2
this receives an output error of
Using Theano backend.
1. Loading Models.
model directory /data2/joshcole/DeepVirFinder/models
Traceback (most recent call last):
File "dvf.py", line 131, in <module>
modDict[contigLengthk] = load_model(os.path.join(modDir, modName))
File "/home/ggb_joshcole/miniconda3/envs/dvf/lib/python3.6/site-packages/keras/engine/saving.py", line 419, in load_model
model = _deserialize_model(f, custom_objects, compile)
File "/home/ggb_joshcole/miniconda3/envs/dvf/lib/python3.6/site-packages/keras/engine/saving.py", line 224, in _deserialize_model
model_config = json.loads(model_config.decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'
From the GitHub repository, what it should return upon a successful run (using example template names) is as follows:
Using Theano backend.
1. Loading Models.
model directory /auto/cmb-panasas2/renj/software/DeepVirFinder/models
2. Encoding and Predicting Sequences.
processing line 1
processing line 1389
3. Done. Thank you for using DeepVirFinder.
output in ./test/crAssphage.fa_gt300bp_dvfpred.txt
Any help for how to fix this error would be greatly appreciated. I have tried to download and jig around with potential conda fixes, but it doesn't appear to be a problem with any dependancies + python is fully up to date.
Thank you for reading
Apologies - I found out it was an error between h5py and tensorflow. Had to downgrade h5py to 2.10.0.
I would like to use an Attribute-Relation File Format(.arff) with scikit-learn for a classification problem. The code runs fine on a Windows 10 machine, however when I try the same code on my other machine with Ubuntu(18.04.1) it throws a confusing error. Here is the code for loading the arff file:
import arff, numpy as np
dataset = arff.load(open('mydataset.arff'))
mydata = np.array(dataset['data'])
And the error I am getting is this:
Traceback (most recent call last):
File "/home/user/Desktop/ml_classification.py", line 14, in <module>
mydata = np.array(dataset['data'])
TypeError: 'generator' object is not subscriptable
What could be the reason for this error and why does it only occur on one machine and not the other?
I'm assuming you are using an old or an unsupported library for ARFF. In order to find out details of the ARFF package you are using, try pip show arff. In my first attempt it showed the url for a google code site (which is defunct now). Try removing the current arff package and install the one at https://pypi.org/project/liac-arff/ with pip install liac-arff. Your code should work with the liac-arff package.
i've just installed base65536 in python, found Here
As a test to see if it works, i've made this script here:
import base65536
a = base65536.encode("Hello World")
print a
i'm using python2.7. When i run it, i get this error:
Traceback (most recent call last):
File "test.py", line 3, in <module>
a = base65536.encode("Hello World")
File "C:\Python27\lib\site-packages\base65536\core.py", line 118, in encode
stream.write(unichr(code_point))
ValueError: unichr() arg not in range(0x10000) (narrow Python build)
Any idea what to do here?
Python2 has two builds: one "narrow" and one "wide", depending on Unicode support. It looks like that library doesn't support the "narrow" build. You should install a "wide" build or hope the library gets updated. It looks like someone filed an issue on it: https://github.com/Parkayun/base65536/issues/4
Or you can use a recent version of Python3, which doesn't have this problem.
I successfully installed javabridge using $pip3 install javabridge on my Mac's virtual environment. But when I tried to import javabridge in my python3 code, this is what I get:
import javabridge
Failed to run /usr/libexec/java_home, defaulting to best guess for Java
Traceback (most recent call last):
File "/Users/puifai/Documents/data_science/venv/venv3/lib/python3.6/site-packages/javabridge/locate.py", line 45, in find_javahome
os.path.join(os.path.dirname(path), "Libraries"),
File "/Users/puifai/Documents/data_science/venv/venv3/bin/../lib/python3.6/posixpath.py", line 92, in join
genericpath._check_arg_types('join', a, *p)
File "/Users/puifai/Documents/data_science/venv/venv3/bin/../lib/python3.6/genericpath.py", line 151, in _check_arg_types
raise TypeError("Can't mix strings and bytes in path components") from None
TypeError: Can't mix strings and bytes in path components
Any ideas on how to fix this? It looks like a problem with Python rather than javabridge?
Pardon the less-than-complete answer, but it has to do with the difference in strings between Python2 and Python3. Working in Python2.7 will at least get you around the problem for the moment. See this post for more background.
I am trying to install pysam and pybedtools modules on python 3.4. But I got an Error:
Collecting pysam
Using cached pysam-0.9.0.tar.gz
Complete output from command python setup.py egg_info:
'.' is not recognized as an internal or external command,
operable program or batch file.
# pysam: htslib mode is shared
# pysam: htslib configure options: None
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\ikirov.CLO\AppData\Local\Temp\pip-build-_me_xeme\pysam\setup.py", line 212, in <module>
sys.abiflags)]
AttributeError: 'module' object has no attribute 'abiflags'
Could you please help me with it?
Hi I got the same error last year during one of my class.
As I know back then, pysam simply won't work with python3 + windows environment.
See this: https://github.com/pysam-developers/pysam/issues/353 looks like it is still unsolved now.
For my homework, I just used this http://bow.codeplex.com/
And my suggestion, just try to use linux or get a python2. Yes I know the scientific field is the slowest for the 2->3 transition. It sucks.