Python源码示例:dragnn.python.bulk.BulkFeatureIdExtractorComponentBuilder()
示例1
def testBulkFeatureIdExtractorOkWithOneFixedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: -1 size: 1
}
""", component_spec)
with tf.Graph().as_default():
comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
# Should not raise errors.
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_training(self.master_state, self.network_states)
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_inference(self.master_state, self.network_states)
示例2
def testBulkFeatureIdExtractorFailsOnLinkedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: -1 size: 1
}
linked_feature {
name: "linked" embedding_dim: -1 size: 1
source_translator: "identity"
source_component: "mock"
}
""", component_spec)
with tf.Graph().as_default():
with self.assertRaises(ValueError):
unused_comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
示例3
def testBulkFeatureIdExtractorOkWithOneFixedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: -1 size: 1
}
""", component_spec)
with tf.Graph().as_default():
comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
# Should not raise errors.
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_training(self.master_state, self.network_states)
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_inference(self.master_state, self.network_states)
示例4
def testBulkFeatureIdExtractorFailsOnLinkedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: -1 size: 1
}
linked_feature {
name: "linked" embedding_dim: -1 size: 1
source_translator: "identity"
source_component: "mock"
}
""", component_spec)
with tf.Graph().as_default():
with self.assertRaises(ValueError):
unused_comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
示例5
def testBulkFeatureIdExtractorOkWithOneFixedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: -1 size: 1
}
""", component_spec)
with tf.Graph().as_default():
comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
# Should not raise errors.
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_training(self.master_state, self.network_states)
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_inference(self.master_state, self.network_states)
示例6
def testBulkFeatureIdExtractorFailsOnLinkedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: -1 size: 1
}
linked_feature {
name: "linked" embedding_dim: -1 size: 1
source_translator: "identity"
source_component: "mock"
}
""", component_spec)
with tf.Graph().as_default():
with self.assertRaises(ValueError):
unused_comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
示例7
def testBulkFeatureIdExtractorOkWithOneFixedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: -1 size: 1
}
""", component_spec)
with tf.Graph().as_default():
comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
# Should not raise errors.
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_training(self.master_state, self.network_states)
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_inference(self.master_state, self.network_states)
示例8
def testBulkFeatureIdExtractorFailsOnLinkedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: -1 size: 1
}
linked_feature {
name: "linked" embedding_dim: -1 size: 1
source_translator: "identity"
source_component: "mock"
}
""", component_spec)
with tf.Graph().as_default():
with self.assertRaises(ValueError):
unused_comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
示例9
def testBulkFeatureIdExtractorOkWithOneFixedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: -1 size: 1
}
""", component_spec)
with tf.Graph().as_default():
comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
# Should not raise errors.
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_training(self.master_state, self.network_states)
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_inference(self.master_state, self.network_states)
示例10
def testBulkFeatureIdExtractorFailsOnLinkedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: -1 size: 1
}
linked_feature {
name: "linked" embedding_dim: -1 size: 1
source_translator: "identity"
source_component: "mock"
}
""", component_spec)
with tf.Graph().as_default():
with self.assertRaises(ValueError):
unused_comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
示例11
def testBulkFeatureIdExtractorOkWithOneFixedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: -1 size: 1
}
""", component_spec)
with tf.Graph().as_default():
comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
# Should not raise errors.
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_training(self.master_state, self.network_states)
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_inference(self.master_state, self.network_states)
示例12
def testBulkFeatureIdExtractorFailsOnLinkedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: -1 size: 1
}
linked_feature {
name: "linked" embedding_dim: -1 size: 1
source_translator: "identity"
source_component: "mock"
}
""", component_spec)
with tf.Graph().as_default():
with self.assertRaises(ValueError):
unused_comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
示例13
def testBulkFeatureIdExtractorOkWithOneFixedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: -1 size: 1
}
""", component_spec)
with tf.Graph().as_default():
comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
# Should not raise errors.
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_training(self.master_state, self.network_states)
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_inference(self.master_state, self.network_states)
示例14
def testBulkFeatureIdExtractorFailsOnLinkedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: -1 size: 1
}
linked_feature {
name: "linked" embedding_dim: -1 size: 1
source_translator: "identity"
source_component: "mock"
}
""", component_spec)
with tf.Graph().as_default():
with self.assertRaises(ValueError):
unused_comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
示例15
def testBulkFeatureIdExtractorOkWithOneFixedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: -1 size: 1
}
""", component_spec)
comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
# Should not raise errors.
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_training(self.master_state, self.network_states)
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_inference(self.master_state, self.network_states)
示例16
def testBulkFeatureIdExtractorFailsOnLinkedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: -1 size: 1
}
linked_feature {
name: "linked" embedding_dim: -1 size: 1
source_translator: "identity"
source_component: "mock"
}
""", component_spec)
with self.assertRaises(ValueError):
unused_comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
示例17
def testBulkFeatureIdExtractorOkWithMultipleFixedFeatures(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed1" embedding_dim: -1 size: 1
}
fixed_feature {
name: "fixed2" embedding_dim: -1 size: 1
}
fixed_feature {
name: "fixed3" embedding_dim: -1 size: 1
}
""", component_spec)
comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
# Should not raise errors.
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_training(self.master_state, self.network_states)
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_inference(self.master_state, self.network_states)
示例18
def testBulkFeatureIdExtractorOkWithOneFixedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: -1 size: 1
}
""", component_spec)
comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
# Should not raise errors.
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_training(self.master_state, self.network_states)
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_inference(self.master_state, self.network_states)
示例19
def testBulkFeatureIdExtractorFailsOnLinkedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: -1 size: 1
}
linked_feature {
name: "linked" embedding_dim: -1 size: 1
source_translator: "identity"
source_component: "mock"
}
""", component_spec)
with self.assertRaises(ValueError):
unused_comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
示例20
def testBulkFeatureIdExtractorOkWithMultipleFixedFeatures(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed1" embedding_dim: -1 size: 1
}
fixed_feature {
name: "fixed2" embedding_dim: -1 size: 1
}
fixed_feature {
name: "fixed3" embedding_dim: -1 size: 1
}
""", component_spec)
comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
# Should not raise errors.
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_training(self.master_state, self.network_states)
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_inference(self.master_state, self.network_states)
示例21
def testBulkFeatureIdExtractorOkWithMultipleFixedFeatures(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed1" embedding_dim: -1 size: 1
}
fixed_feature {
name: "fixed2" embedding_dim: -1 size: 1
}
fixed_feature {
name: "fixed3" embedding_dim: -1 size: 1
}
""", component_spec)
with tf.Graph().as_default():
comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
# Should not raise errors.
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_training(self.master_state, self.network_states)
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_inference(self.master_state, self.network_states)
示例22
def testBulkFeatureIdExtractorFailsOnEmbeddedFixedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: 2 size: 1
}
""", component_spec)
with tf.Graph().as_default():
with self.assertRaises(ValueError):
unused_comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
示例23
def testBulkFeatureIdExtractorOkWithMultipleFixedFeatures(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed1" embedding_dim: -1 size: 1
}
fixed_feature {
name: "fixed2" embedding_dim: -1 size: 1
}
fixed_feature {
name: "fixed3" embedding_dim: -1 size: 1
}
""", component_spec)
with tf.Graph().as_default():
comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
# Should not raise errors.
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_training(self.master_state, self.network_states)
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_inference(self.master_state, self.network_states)
示例24
def testBulkFeatureIdExtractorFailsOnEmbeddedFixedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: 2 size: 1
}
""", component_spec)
with tf.Graph().as_default():
with self.assertRaises(ValueError):
unused_comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
示例25
def testBulkFeatureIdExtractorOkWithMultipleFixedFeatures(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed1" embedding_dim: -1 size: 1
}
fixed_feature {
name: "fixed2" embedding_dim: -1 size: 1
}
fixed_feature {
name: "fixed3" embedding_dim: -1 size: 1
}
""", component_spec)
with tf.Graph().as_default():
comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
# Should not raise errors.
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_training(self.master_state, self.network_states)
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_inference(self.master_state, self.network_states)
示例26
def testBulkFeatureIdExtractorFailsOnEmbeddedFixedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: 2 size: 1
}
""", component_spec)
with tf.Graph().as_default():
with self.assertRaises(ValueError):
unused_comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
示例27
def testBulkFeatureIdExtractorOkWithMultipleFixedFeatures(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed1" embedding_dim: -1 size: 1
}
fixed_feature {
name: "fixed2" embedding_dim: -1 size: 1
}
fixed_feature {
name: "fixed3" embedding_dim: -1 size: 1
}
""", component_spec)
with tf.Graph().as_default():
comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
# Should not raise errors.
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_training(self.master_state, self.network_states)
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_inference(self.master_state, self.network_states)
示例28
def testBulkFeatureIdExtractorFailsOnEmbeddedFixedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: 2 size: 1
}
""", component_spec)
with tf.Graph().as_default():
with self.assertRaises(ValueError):
unused_comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
示例29
def testBulkFeatureIdExtractorOkWithMultipleFixedFeatures(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed1" embedding_dim: -1 size: 1
}
fixed_feature {
name: "fixed2" embedding_dim: -1 size: 1
}
fixed_feature {
name: "fixed3" embedding_dim: -1 size: 1
}
""", component_spec)
with tf.Graph().as_default():
comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)
# Should not raise errors.
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_training(self.master_state, self.network_states)
self.network_states[component_spec.name] = component.NetworkState()
comp.build_greedy_inference(self.master_state, self.network_states)
示例30
def testBulkFeatureIdExtractorFailsOnEmbeddedFixedFeature(self):
component_spec = spec_pb2.ComponentSpec()
text_format.Parse("""
name: "test"
network_unit {
registered_name: "IdentityNetwork"
}
fixed_feature {
name: "fixed" embedding_dim: 2 size: 1
}
""", component_spec)
with tf.Graph().as_default():
with self.assertRaises(ValueError):
unused_comp = bulk_component.BulkFeatureIdExtractorComponentBuilder(
self.master, component_spec)