Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
4364390a
You need to sign in or sign up before continuing.
Commit
4364390a
authored
Nov 13, 2017
by
Ivan Bogatyy
Committed by
calberti
Nov 13, 2017
Browse files
Release DRAGNN bulk networks (#2785)
* Release DRAGNN bulk networks
parent
638fd759
Changes
166
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
140 additions
and
3 deletions
+140
-3
research/syntaxnet/syntaxnet/util/resources.py
research/syntaxnet/syntaxnet/util/resources.py
+74
-0
research/syntaxnet/syntaxnet/util/resources_test.py
research/syntaxnet/syntaxnet/util/resources_test.py
+44
-0
research/syntaxnet/syntaxnet/whole_sentence_features.h
research/syntaxnet/syntaxnet/whole_sentence_features.h
+6
-2
research/syntaxnet/tensorflow
research/syntaxnet/tensorflow
+1
-1
research/syntaxnet/third_party/utf/LICENSE
research/syntaxnet/third_party/utf/LICENSE
+13
-0
research/syntaxnet/tools/bazel.rc
research/syntaxnet/tools/bazel.rc
+2
-0
No files found.
research/syntaxnet/syntaxnet/util/resources.py
0 → 100644
View file @
4364390a
# Copyright 2017 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,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Utils for loading resources (data files) from the SyntaxNet source tree.
The resources must be data dependencies of the relevant py_*() build target.
Example usage:
from syntaxnet.util import resources
data_blob = resources.GetSyntaxNetResource(
'syntaxnet/testdata/context.pbtxt')
"""
import
os
# Absolute path to the root directory holding syntaxnet. Resource paths are
# interpreted relative to this path.
_ROOT_DIR
=
os
.
path
.
dirname
(
# .../
os
.
path
.
dirname
(
# .../syntaxnet/
os
.
path
.
dirname
(
# .../syntaxnet/util/
os
.
path
.
abspath
(
__file__
))))
# .../syntaxnet/util/resources.py
def
GetSyntaxNetResourceAsFile
(
path
):
"""Returns a resource as an opened read-only file.
Args:
path: Relative path to the resource, which must be a Bazel data dependency.
Returns:
Opened read-only file pointing to resource data.
Raises:
IOError: If the resource cannot be loaded.
"""
path
=
os
.
path
.
join
(
_ROOT_DIR
,
path
)
if
os
.
path
.
isdir
(
path
):
raise
IOError
(
'Resource "{}" is not a file'
.
format
(
path
))
if
not
os
.
path
.
isfile
(
path
):
raise
IOError
(
'Resource "{}" not found; is it a data dependency?'
.
format
(
path
))
return
open
(
path
,
'rb'
)
def
GetSyntaxNetResource
(
path
):
"""Returns the content of a resource.
Args:
path: Relative path to the resource, which must be a Bazel data dependency.
Returns:
Raw content of the resource.
Raises:
IOError: If the resource cannot be loaded.
"""
with
GetSyntaxNetResourceAsFile
(
path
)
as
resource_file
:
return
resource_file
.
read
()
research/syntaxnet/syntaxnet/util/resources_test.py
0 → 100644
View file @
4364390a
# Copyright 2017 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,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Tests for resources."""
from
tensorflow.python.platform
import
googletest
from
syntaxnet.util
import
resources
class
ResourcesTest
(
googletest
.
TestCase
):
"""Testing rig."""
def
testInvalidResource
(
self
):
for
path
in
[
'bad/path/to/no/file'
,
'syntaxnet/testdata'
,
'syntaxnet/testdata/context.pbtxt'
,
]:
with
self
.
assertRaises
(
IOError
):
resources
.
GetSyntaxNetResource
(
path
)
with
self
.
assertRaises
(
IOError
):
resources
.
GetSyntaxNetResourceAsFile
(
path
)
def
testValidResource
(
self
):
path
=
'syntaxnet/testdata/hello.txt'
self
.
assertEqual
(
'hello world
\n
'
,
resources
.
GetSyntaxNetResource
(
path
))
with
resources
.
GetSyntaxNetResourceAsFile
(
path
)
as
resource_file
:
self
.
assertEqual
(
'hello world
\n
'
,
resource_file
.
read
())
if
__name__
==
'__main__'
:
googletest
.
main
()
research/syntaxnet/syntaxnet/whole_sentence_features.h
View file @
4364390a
...
@@ -16,11 +16,12 @@ limitations under the License.
...
@@ -16,11 +16,12 @@ limitations under the License.
// Features for whole Sentence objects. Contrast with SentenceFeature, which
// Features for whole Sentence objects. Contrast with SentenceFeature, which
// operates on tokens within Sentences.
// operates on tokens within Sentences.
#include "syntaxnet/feature_extractor.h"
#ifndef SYNTAXNET_WHOLE_SENTENCE_FEATURES_H_
#ifndef SYNTAXNET_WHOLE_SENTENCE_FEATURES_H_
#define SYNTAXNET_WHOLE_SENTENCE_FEATURES_H_
#define SYNTAXNET_WHOLE_SENTENCE_FEATURES_H_
#include "syntaxnet/feature_extractor.h"
#include "syntaxnet/registry.h"
namespace
syntaxnet
{
namespace
syntaxnet
{
// Type of feature functions whose focus is a whole sentence.
// Type of feature functions whose focus is a whole sentence.
...
@@ -30,6 +31,9 @@ typedef FeatureFunction<Sentence> WholeSentenceFeatureFunction;
...
@@ -30,6 +31,9 @@ typedef FeatureFunction<Sentence> WholeSentenceFeatureFunction;
#define REGISTER_WHOLE_SENTENCE_FEATURE_FUNCTION(name, type) \
#define REGISTER_WHOLE_SENTENCE_FEATURE_FUNCTION(name, type) \
REGISTER_SYNTAXNET_FEATURE_FUNCTION(WholeSentenceFeatureFunction, name, type)
REGISTER_SYNTAXNET_FEATURE_FUNCTION(WholeSentenceFeatureFunction, name, type)
DECLARE_SYNTAXNET_CLASS_REGISTRY
(
"whole sentence feature function"
,
WholeSentenceFeatureFunction
);
}
// namespace syntaxnet
}
// namespace syntaxnet
#endif // SYNTAXNET_WHOLE_SENTENCE_FEATURES_H_
#endif // SYNTAXNET_WHOLE_SENTENCE_FEATURES_H_
tensorflow
@
c52cdc03
Compare
90267567
...
c52cdc03
Subproject commit
9026756727e7c6782ab89c181c80b2117bf78c05
Subproject commit
c52cdc03a67ceae9ecc8c00025d3c60f54833e2d
research/syntaxnet/third_party/utf/LICENSE
0 → 100644
View file @
4364390a
/*
* The authors of this software are Rob Pike and Ken Thompson.
* Copyright (c) 1998-2002 by Lucent Technologies.
* Permission to use, copy, modify, and distribute this software for any
* purpose without fee is hereby granted, provided that this entire notice
* is included in all copies of any software which is or includes a copy
* or modification of this software and in all copies of the supporting
* documentation for such software.
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
*/
research/syntaxnet/tools/bazel.rc
View file @
4364390a
import %workspace%/tensorflow/.tf_configure.bazelrc
build:cuda --crosstool_top=@local_config_cuda//crosstool:toolchain
build:cuda --crosstool_top=@local_config_cuda//crosstool:toolchain
build:cuda --define=using_cuda=true --define=using_cuda_nvcc=true
build:cuda --define=using_cuda=true --define=using_cuda_nvcc=true
build:win-cuda --define=using_cuda=true --define=using_cuda_nvcc=true
build:win-cuda --define=using_cuda=true --define=using_cuda_nvcc=true
...
...
Prev
1
…
5
6
7
8
9
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment