Skip to content

Instantly share code, notes, and snippets.

View surmenok's full-sized avatar

Pavel Surmenok surmenok

View GitHub Profile
import struct
from tensorflow.core.example import example_pb2
with open(output_filename, 'wb') as writer:
body = 'body'
title = 'title'
tf_example = example_pb2.Example()
tf_example.features.feature['article'].bytes_list.value.extend([body])
tf_example.features.feature['abstract'].bytes_list.value.extend([title])
python textsum_data_convert.py \
--command text_to_vocabulary \
--in_directories cnn/stories \
--out_files cnn-vocab
python textsum_data_convert.py \
--command text_to_binary \
--in_directories cnn/stories \
--out_files cnn-train.bin,cnn-validation.bin,cnn-test.bin \
--split 0.8,0.15,0.05
Train on CNN data (cnn-train, cnn-vocab):
bazel-bin/textsum/seq2seq_attention \
--mode=train \
--article_key=article \
--abstract_key=abstract \
--data_path=data/cnn-train.bin \
--vocab_path=data/cnn-vocab.bin \
--log_root=log_root \
--train_dir=log_root/train \
def _next_device(self):
"""Round robin the gpu device. (Reserve last gpu for expensive op)."""
if self._num_gpus == 0:
return ''
dev = '/gpu:%d' % self._cur_gpu
self._cur_gpu = (self._cur_gpu + 1) % (self._num_gpus-1)
return dev
Thu Oct 13 20:14:11 2016
+------------------------------------------------------+
| NVIDIA-SMI 352.39 Driver Version: 352.39 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 980 Ti Off | 0000:01:00.0 Off | N/A |
| 29% 46C P8 26W / 250W | 124MiB / 6142MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
Sat Oct 15 01:51:04 2016
+------------------------------------------------------+
| NVIDIA-SMI 352.39 Driver Version: 352.39 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 980 Ti Off | 0000:01:00.0 Off | N/A |
| 32% 53C P2 96W / 250W | 5881MiB / 6142MiB | 56% Default |
+-------------------------------+----------------------+----------------------+
def isRefundRequest(message):
return 'pay' in message or 'order' in message
r = Rule(
And(
Or('cancel', 'close'),
'membership',
Respond('Would you like to cancel your membership immediately?'))
u: (<<[cancel close] membership>>)
Would you like to cancel your membership immediately?
# Copyright 2014 Google Inc. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,