Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to tensorflow 2 #46

Open
berndverst opened this issue Apr 18, 2020 · 6 comments
Open

Migrate to tensorflow 2 #46

berndverst opened this issue Apr 18, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@berndverst
Copy link

Can you please make your code compatible with Tensorflow 2.0+ by default.

Pretty easy to do with no code changes, see:
https://www.tensorflow.org/guide/migrate

Just add this wherever you previously imported tensorflow:

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

And update your requirements.txt per #45

@lindawangg lindawangg added the enhancement New feature or request label Apr 18, 2020
@Parag0506
Copy link

+1 for this

@iSean97
Copy link

iSean97 commented Jun 18, 2020

Hi there, I got stuck running at train_tf.py.
I've added "import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()" into Juypter Notebook but it doesn't run :/

WARNING:tensorflow:From C:\Users\user.conda\envs\tensorflow_env\lib\site-packages\tensorflow_core\python\compat\v2_compat.py:88: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term
usage: ipykernel_launcher.py [-h] [--epochs EPOCHS] [--lr LR] [--bs BS]
[--weightspath WEIGHTSPATH] [--metaname METANAME]
[--ckptname CKPTNAME] [--trainfile TRAINFILE]
[--testfile TESTFILE] [--name NAME]
[--datadir DATADIR] [--covid_weight COVID_WEIGHT]
[--covid_percent COVID_PERCENT]
[--input_size INPUT_SIZE]
[--top_percent TOP_PERCENT]
[--in_tensorname IN_TENSORNAME]
[--out_tensorname OUT_TENSORNAME]
[--logit_tensorname LOGIT_TENSORNAME]
[--label_tensorname LABEL_TENSORNAME]
[--weights_tensorname WEIGHTS_TENSORNAME]
ipykernel_launcher.py: error: unrecognized arguments: -f C:\Users\user\AppData\Roaming\jupyter\runtime\kernel-d40f5aa3-b4a4-4d37-8ad4-dd87ed3aeddd.json
An exception has occurred, use %tb to see the full traceback.

SystemExit: 2

C:\Users\user.conda\envs\tensorflow_env\lib\site-packages\IPython\core\interactiveshell.py:3339: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)

@berndverst
Copy link
Author

@iSean97 you have to add that at the very beginning of the notebook file and make sure you don't have other tensorflow imports.

Also, your error is actually mentioning an argument -f. Not sure how you are actually doing your training and what your environment is.

I recommend troubleshooting this general tensorflow problem elsewhere as it is not related the project here.

@yoyongbo
Copy link

yoyongbo commented Apr 8, 2021

Hi there
I am very interested in this model architecture, is there something like
model.summary()
in TensorFlow1?
I am curious what kind of pooling and activation functions the model uses.
I can see that the last layer uses a sigmoid.
Thanks!!

@haydengunraj
Copy link
Collaborator

haydengunraj commented Apr 8, 2021

Hi @yoyongbo ,

I don't believe there's a simple print like model.summary() provides, but there are a couple of things you can do to visualize the model. The best way to do it would be using tensorboard, which lets you interactively explore the model graph. You can prepare the model for viewing on tensorboard like this:

import tensorflow as tf

out_dir = './tensorboard_graph'
meta_file = 'models/COVID-Net_CXR-2/model.meta'

graph = tf.Graph()
with graph.as_default():
    tf.train.import_meta_graph(meta_file)
    writer = tf.summary.FileWriter(out_dir, graph)
    writer.close()

You can then run tensorboard and view the graph in a browser at localhost:6006 (or whichever port you're using) via this command

tensorboard --logdir=./tensorboard_graph --port=6006

If you don't care about the structure and you just want a list of all the operations (in no particular order), you can try

import tensorflow as tf

meta_file = 'models/COVID-Net_CXR-2/model.meta'

graph = tf.Graph()
with graph.as_default():
    tf.train.import_meta_graph(meta_file)

    for n in graph.as_graph_def().node:
        print(n.name)

@yoyongbo
Copy link

yoyongbo commented Apr 8, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants