当前位置: 首页>>代码示例>>Python>>正文


Python Model.evaluate方法代码示例

本文整理汇总了Python中model.Model.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Python Model.evaluate方法的具体用法?Python Model.evaluate怎么用?Python Model.evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.Model的用法示例。


在下文中一共展示了Model.evaluate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import evaluate [as 别名]
class Experiment:
    """
    Machine Learning Experiment Interface
    """

    def __init__(self):
        self.model = Model()
        self.description = "awesome-experiment"
        pass

    def set_description(self, description):
        """
        :type description: str
        """
        self.description = description

    def get_data(self):
        raise NotImplementedError()

    def set_model(self, model):
        """
        :type model: Model
        """
        self.model = model

    def run(self):
        print " ====================================== "
        print "|    Data Gathering & Preparation      |"
        print " ====================================== "
        self.get_data()
        print " ====================================== "
        print "|            Model Building            |"
        print " ====================================== "
        self.model.fit()
        print " ====================================== "
        print "|            Model Evaluate            |"
        print " ====================================== "
        self.model.evaluate()
开发者ID:rain1024,项目名称:kaggle-drawbridge,代码行数:40,代码来源:experiment.py

示例2: test_evaulate_returns_correct_shapes_for_trivial_cases

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import evaluate [as 别名]
 def test_evaulate_returns_correct_shapes_for_trivial_cases(self):
     model = Model([np.random.rand(1,2), np.random.rand(1,2)])
     result = model.evaluate(np.random.rand(1,1))
     self.assertEqual(result.shape, (1,1))
开发者ID:zpbappi,项目名称:python-neural-network,代码行数:6,代码来源:model_tests.py

示例3: test_evaluate_returns_correct_output_shape

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import evaluate [as 别名]
 def test_evaluate_returns_correct_output_shape(self):
     model = Model([np.random.rand(10, 5), np.random.rand(10, 11), np.random.rand(5, 11), np.random.rand(3, 6)])
     result = model.evaluate([[r*5+c for c in range(4)] for r in range(100)])
     actual = result.shape
     expected = (100, 3)
     self.assertEqual(actual, expected)
开发者ID:zpbappi,项目名称:python-neural-network,代码行数:8,代码来源:model_tests.py

示例4: test_evaluation_should_throw_for_invalid_input_dimensions

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import evaluate [as 别名]
 def test_evaluation_should_throw_for_invalid_input_dimensions(self):
     model = Model([np.random.rand(10, 5), np.random.rand(10, 11), np.random.rand(5, 11), np.random.rand(3, 6)])
     with self.assertRaises(ValueError):
         model.evaluate([x for x in range(2)])
开发者ID:zpbappi,项目名称:python-neural-network,代码行数:6,代码来源:model_tests.py

示例5: test_model_should_also_take_multiple_rows

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import evaluate [as 别名]
 def test_model_should_also_take_multiple_rows(self):
     model = Model([np.random.rand(10, 5), np.random.rand(10, 11), np.random.rand(5, 11), np.random.rand(3, 6)])
     model.evaluate([[x for x in range(4)], [x**2 for x in range(4)]])
开发者ID:zpbappi,项目名称:python-neural-network,代码行数:5,代码来源:model_tests.py

示例6: test_model_should_take_a_single_input_row

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import evaluate [as 别名]
 def test_model_should_take_a_single_input_row(self):
     model = Model([np.random.rand(10, 5), np.random.rand(10, 11), np.random.rand(5, 11), np.random.rand(3, 6)])
     model.evaluate([x for x in range(4)])
开发者ID:zpbappi,项目名称:python-neural-network,代码行数:5,代码来源:model_tests.py

示例7: print

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import evaluate [as 别名]
            if loss < best:
                print('New best validation loss! Was: {}, Now: {}'.format(best, loss))
                best = loss
                wait = 0
            else:
                wait += 1
                print('Validation loss did not improve for {}/{} epochs.'.format(wait, patience))

            if wait == 2:
                print('Stopping early. Validation loss did not improve for {}/{} epochs.'.format(wait, patience))
                break


        model.summary_writer.close()
        scores_total.append(score)

        print('Begin evaluation...')
        predictions = model.evaluate(X_test)
        predictions_total.append(predictions)

    num_folds += 1

score_geom = calc_geom(scores_total, num_folds)
predictions_geom = calc_geom_arr(predictions_total, num_folds)

print('Writing submission for {} folds, score: {}...'.format(num_folds, score_geom))
submission_dest = os.path.join(SUMMARY_PATH, 'submission_{}_{}.csv'.format(int(time.time()), score_geom))
write_submission(predictions_geom, X_test_ids, submission_dest)

print('Done.')
开发者ID:ambertch,项目名称:distracted-drivers-tf,代码行数:32,代码来源:main.py

示例8: get_trimmed_glove_vectors

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import evaluate [as 别名]
    vocab_labels, lowercase=False, label_vocab=True)

# get pre trained embeddings
embeddings = get_trimmed_glove_vectors(config.trimmed_filename)

test_filepath, _ = write_clear_data_pd(
    config.test_filename, config.DEFAULT, domain=config.domain)
test = Dataset(test_filepath, processing_word, processing_label,
               config.max_iter)

# build model
model = Model(
    config, embeddings, ntags=len(vocab_labels), nchars=len(vocab_chars))
# build graph
model.build_graph()
model.evaluate(test, vocab_labels)

# processing_word = get_processing_word(
#     vocab_words, vocab_chars, lowercase=True, chars=config.chars)
# tags = load_vocab(config.labels_filename)
# idx_to_tag = {idx: tag for tag, idx in vocab_labels.items()}
# saver = tf.train.Saver()
#     with tf.Session() as sess:
#         saver.restore(sess, self.config.model_output)

# import tensorflow as tf

# config = Config()
# tags = load_vocab(config.labels_filename)
# # saver = tf.train.Saver()
# saver = tf.train.import_meta_graph(config.model_output + "best.meta")
开发者ID:lacozhang,项目名称:torchcode,代码行数:33,代码来源:infer.py


注:本文中的model.Model.evaluate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。