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

Fix error to parse FLAGS #127 issue of eval.py #165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,31 @@
from text_cnn import TextCNN
from tensorflow.contrib import learn
import csv
import argparse

# Parameters
# ==================================================

# Data Parameters
tf.flags.DEFINE_string("positive_data_file", "./data/rt-polaritydata/rt-polarity.pos", "Data source for the positive data.")
tf.flags.DEFINE_string("negative_data_file", "./data/rt-polaritydata/rt-polarity.neg", "Data source for the negative data.")
parser = argparse.ArgumentParser()

# Eval Parameters
tf.flags.DEFINE_integer("batch_size", 64, "Batch Size (default: 64)")
tf.flags.DEFINE_string("checkpoint_dir", "", "Checkpoint directory from training run")
tf.flags.DEFINE_boolean("eval_train", False, "Evaluate on all training data")
#Data Parameters
parser.add_argument('--positive_data_file', type=str, default='./data/rt-polaritydata/rt-polarity.pos', help='Data source for the positive data.')
parser.add_argument('--negative_data_file', type=str, default='./data/rt-polaritydata/rt-polarity.neg', help='Data source for the positive data.')

# Misc Parameters
tf.flags.DEFINE_boolean("allow_soft_placement", True, "Allow device soft device placement")
tf.flags.DEFINE_boolean("log_device_placement", False, "Log placement of ops on devices")
#Eval Parameters
parser.add_argument('--batch_size', type=int, default=64, help='Batch Size (default: 64).')
parser.add_argument('--checkpoint_dir', type=str, default=None, help='Checkpoint directory from training run.')
parser.add_argument('--eval_train', type=bool, default=False, help='Evaluate on all training data.')

#Misc Parameters
parser.add_argument('--allow_soft_placement', type=bool, default=True, help='Allow device soft device placement.')
parser.add_argument('--log_device_placement', type=bool, default=False, help='Log placement of ops on devices.')

FLAGS = parser.parse_args()

FLAGS = tf.flags.FLAGS
FLAGS._parse_flags()
print("\nParameters:")
for attr, value in sorted(FLAGS.__flags.items()):
print("{}={}".format(attr.upper(), value))
for attr in vars(FLAGS):
print("{}={}".format(attr.upper(), getattr(FLAGS, attr)))
print("")

# CHANGE THIS: Load data. Load your own data here
Expand Down