function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def test_view_person_othername_list_unauthorized(self): response = self.client.get("/en/persons/8497ba86-7485-42d2-9596-2ab14520f1f4/othernames/") self.assertEqual(response.status_code, status.HTTP_200_OK)
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_view_person_othername_details_unauthorized(self): response = self.client.get( "/en/persons/8497ba86-7485-42d2-9596-2ab14520f1f4/othernames/cf93e73f-91b6-4fad-bf76-0782c80297a8/" ) self.assertEqual(response.status_code, status.HTTP_200_OK)
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_view_person_othername_details_authorized(self): token = Token.objects.get(user__username="admin") self.client.credentials(HTTP_AUTHORIZATION='Token ' + token.key) response = self.client.get( "/en/persons/8497ba86-7485-42d2-9596-2ab14520f1f4/othernames/cf93e73f-91b6-4fad-bf76...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_create_person_othername_unauthorized(self): data = { "name": "jane", "family_name": "jambul", "given_name": "test person", "start_date": "1950-01-01", "end_date": "2010-01-01", } response = self.client.post( "/en/pe...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_update_person_othername_unauthorized(self): data = { "family_name": "jambul", } person = Person.objects.language('en').get(id='8497ba86-7485-42d2-9596-2ab14520f1f4') other_name = person.other_names.language('en').get(id="cf93e73f-91b6-4fad-bf76-0782c80297a8") ...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_update_person_othername_authorized(self): data = { "family_name": "jambul", } token = Token.objects.get(user__username="admin") self.client.credentials(HTTP_AUTHORIZATION='Token ' + token.key) response = self.client.put( "/en/persons/8497ba86-748...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_delete_person_othername_unauthorized(self): response = self.client.delete( "/en/persons/8497ba86-7485-42d2-9596-2ab14520f1f4/othernames/cf93e73f-91b6-4fad-bf76-0782c80297a8/" ) self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_delete_person_othername_authorized(self): token = Token.objects.get(user__username="admin") self.client.credentials(HTTP_AUTHORIZATION='Token ' + token.key) response = self.client.delete( "/en/persons/8497ba86-7485-42d2-9596-2ab14520f1f4/othernames/cf93e73f-91b6-4fad-bf76-07...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_get_person_identifier_link_list_unauthorized(self): # identifier af7c01b5-1c4f-4c08-9174-3de5ff270bdb # link 9c9a2093-c3eb-4b51-b869-0d3b4ab281fd # person 8497ba86-7485-42d2-9596-2ab14520f1f4 response = self.client.get( "/en/persons/8497ba86-7485-42d2-9596-2ab14520f...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_get_person_identifier_link_detail_unauthorized(self): response = self.client.get( "/en/persons/8497ba86-7485-42d2-9596-2ab14520f1f4/identifiers/af7c01b5-1c4f-4c08-9174-3de5ff270bdb/links/9c9a2093-c3eb-4b51-b869-0d3b4ab281fd/" ) self.assertEqual(response.status_code, status.H...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_get_person_identifier_link_detail_authorized(self): token = Token.objects.get(user__username="admin") self.client.credentials(HTTP_AUTHORIZATION='Token ' + token.key) response = self.client.get( "/en/persons/8497ba86-7485-42d2-9596-2ab14520f1f4/identifiers/af7c01b5-1c4f-4c08...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_create_person_identifier_link_unauthorized(self): data = { "url": "http://twitter.com/sinarproject" } response = self.client.post( "/en/persons/8497ba86-7485-42d2-9596-2ab14520f1f4/identifiers/af7c01b5-1c4f-4c08-9174-3de5ff270bdb/links/", data ...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_update_person_identifier_link_unauthorized(self): data = { "note":"This is a nested link" } response = self.client.put( "/en/persons/8497ba86-7485-42d2-9596-2ab14520f1f4/identifiers/af7c01b5-1c4f-4c08-9174-3de5ff270bdb/links/9c9a2093-c3eb-4b51-b869-0d3b4ab281fd/"...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_update_person_identifier_link_authorized(self): data = { "note":"This is a nested link" } token = Token.objects.get(user__username="admin") self.client.credentials(HTTP_AUTHORIZATION='Token ' + token.key) response = self.client.put( "/en/persons...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_delete_person_identifier_link_unauthorized(self): response = self.client.delete( "/en/persons/8497ba86-7485-42d2-9596-2ab14520f1f4/identifiers/af7c01b5-1c4f-4c08-9174-3de5ff270bdb/links/9c9a2093-c3eb-4b51-b869-0d3b4ab281fd/" ) self.assertEqual(response.status_code, status.HT...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_delete_person_identifier_link_authorized(self): token = Token.objects.get(user__username="admin") self.client.credentials(HTTP_AUTHORIZATION='Token ' + token.key) response = self.client.delete( "/en/persons/8497ba86-7485-42d2-9596-2ab14520f1f4/identifiers/af7c01b5-1c4f-4c08-...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_list_person_othername_link(self): response = self.client.get( "/en/persons/8497ba86-7485-42d2-9596-2ab14520f1f4/othernames/cf93e73f-91b6-4fad-bf76-0782c80297a8/links/" ) self.assertEqual(response.status_code, status.HTTP_200_OK)
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_show_person_othername_link_detail(self): response = self.client.get( "/en/persons/8497ba86-7485-42d2-9596-2ab14520f1f4/othernames/cf93e73f-91b6-4fad-bf76-0782c80297a8/links/4d8d71c4-20ea-4ed1-ae38-4b7d7550cdf6/" ) self.assertEqual(response.status_code, status.HTTP_200_OK)
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_create_person_othername_link_authorized(self): data = { "url": "http://github.com/sinar" } token = Token.objects.get(user__username="admin") self.client.credentials(HTTP_AUTHORIZATION='Token ' + token.key) response = self.client.post( "/en/perso...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_update_person_othername_link_not_exist_authorized(self): data = { "note": "Just a link" } token = Token.objects.get(user__username="admin") self.client.credentials(HTTP_AUTHORIZATION='Token ' + token.key) response = self.client.put( "/en/persons...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_update_person_othername_link_authorized(self): data = { "note": "Just a link" } token = Token.objects.get(user__username="admin") self.client.credentials(HTTP_AUTHORIZATION='Token ' + token.key) response = self.client.put( "/en/persons/8497ba86-...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_delete_person_othername_link_not_exist_authorized(self): token = Token.objects.get(user__username="admin") self.client.credentials(HTTP_AUTHORIZATION='Token ' + token.key) response = self.client.delete( "/en/persons/8497ba86-7485-42d2-9596-2ab14520f1f4/othernames/cf93e73f-91...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_delete_person_othername_link_authorized(self): token = Token.objects.get(user__username="admin") self.client.credentials(HTTP_AUTHORIZATION='Token ' + token.key) response = self.client.delete( "/en/persons/8497ba86-7485-42d2-9596-2ab14520f1f4/othernames/cf93e73f-91b6-4fad-bf...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_list_person_contact_link(self): response = self.client.get( "/en/persons/8497ba86-7485-42d2-9596-2ab14520f1f4/contact_details/2256ec04-2d1d-4994-b1f1-16d3f5245441/links/" ) self.assertEqual(response.status_code, status.HTTP_200_OK)
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_show_person_contact_link(self): response = self.client.get( "/en/persons/8497ba86-7485-42d2-9596-2ab14520f1f4/contact_details/2256ec04-2d1d-4994-b1f1-16d3f5245441/links/6d0afb46-67d4-4708-87c4-4d51ce99767e/" ) self.assertEqual(response.status_code, status.HTTP_200_OK)
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_create_person_contact_link_authorized(self): data = { "url": "http://github.com/sinar" } token = Token.objects.get(user__username="admin") self.client.credentials(HTTP_AUTHORIZATION='Token ' + token.key) response = self.client.post( "/en/persons/8...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_update_person_contact_link_not_exist_authorized(self): data = { "note": "Just a link" } token = Token.objects.get(user__username="admin") self.client.credentials(HTTP_AUTHORIZATION='Token ' + token.key) response = self.client.put( "/en/persons/84...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_update_person_contact_link_authorized(self): data = { "note": "Just a link" } token = Token.objects.get(user__username="admin") self.client.credentials(HTTP_AUTHORIZATION='Token ' + token.key) response = self.client.put( "/en/persons/8497ba86-74...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_delete_person_contact_link_not_exist_authorized(self): token = Token.objects.get(user__username="admin") self.client.credentials(HTTP_AUTHORIZATION='Token ' + token.key) response = self.client.delete( "/en/persons/8497ba86-7485-42d2-9596-2ab14520f1f4/contact_details/2256ec04...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_fetch_non_empty_field_person_serializer(self): person = Person.objects.untranslated().get(id='8497ba86-7485-42d2-9596-2ab14520f1f4') serializer = PersonSerializer(person, language='en') data = serializer.data self.assertEqual(data["name"], "John")
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_fetch_not_empty_relation_person_serializer(self): person = Person.objects.untranslated().get(id='8497ba86-7485-42d2-9596-2ab14520f1f4') serializer = PersonSerializer(person, language='en') data = serializer.data self.assertTrue(data["other_names"])
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_create_person_with_all_field_serializer(self): person_data = { "name": "joe", "family_name": "doe", "given_name": "joe jambul", "additional_name": "not john doe", "gender": "unknown", "summary": "person unit test api", ...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_create_links_person_serializers(self): person_data = { "links": [ { "url": "http://twitter.com/sweemeng", } ] } person = Person.objects.language('en').get(id='ab1a5788e5bae955c048748fa6af0e97') person_s...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_update_create_nested_links_persons_serializer(self): person_data = { "id":"ab1a5788e5bae955c048748fa6af0e97", "contact_details":[ { "id": "a66cb422-eec3-4861-bae1-a64ae5dbde61", "links": [{ "url": "h...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_create_identifier_person_serializer(self): person_data = { "identifiers": [ { "scheme": "IC", "identifier": "129031309", } ] } person = Person.objects.language('en').get(id='ab1a5788e5bae955c...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_create_contact_person_serializer(self): person_data = { "contact_details": [ { "type":"twitter", "value": "sinarproject", } ] } person = Person.objects.language('en').get(id='8497ba86-7485-42...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_create_other_name_person_serializer(self): person_data = { "other_names": [ { "name": "jane", "family_name": "jambul", "given_name": "test person", "start_date": "1950-01-01", ...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_create_person_invalid_date_serializer(self): person_data = { "name": "joe", "family_name": "doe", "given_name": "joe jambul", "additional_name": "not john doe", "gender": "unknown", "summary": "person unit test api", "h...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_create_person_translated_serializer(self): person_data = { "name": "joe", "family_name": "doe", "given_name": "joe jambul", "additional_name": "bukan john doe", "gender": "tak tahu", "summary": "orang ujian", "honorific...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_load_translated_person_membership_organization(self): person = Person.objects.untranslated().get(id="078541c9-9081-4082-b28f-29cbb64440cb") person_serializer = PersonSerializer(person, language="ms") data = person_serializer.data for membership in data["memberships"]: ...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_fetch_person_minimized_serializer(self): person = Person.objects.untranslated().get(id='8497ba86-7485-42d2-9596-2ab14520f1f4') person_serializer = MinPersonSerializer(person) membership_count = person.memberships.count() self.assertTrue(len(person_serializer.data["memberships"]...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_view_person_list(self): response = self.client.get("/en/persons/") self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertTrue("page" in response.data) self.assertEqual(response.data["per_page"], settings.REST_FRAMEWORK["PAGE_SIZE"]) self.assertEqual(respo...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_view_person_detail_not_exist(self): response = self.client.get("/en/persons/not_exist/") self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_create_person_authorized(self): person_data = { "name": "joe", "family_name": "doe", "given_name": "joe jambul", "additional_name": "not john doe", "gender": "unknown", "summary": "person unit test api", "honorific_pref...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_update_person_not_exist_unauthorized(self): person_data = { "given_name": "jerry jambul", } response = self.client.put("/en/persons/not_exist/", person_data) self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_update_person_not_exist_authorized(self): person_data = { "given_name": "jerry jambul", } token = Token.objects.get(user__username="admin") self.client.credentials(HTTP_AUTHORIZATION='Token ' + token.key) response = self.client.put("/en/persons/not_exist/", p...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_create_person_links_authorized(self): person_data = { "links": [ { "url": "http://twitter.com/sweemeng", } ] } token = Token.objects.get(user__username="admin") self.client.credentials(HTTP_AUTHORIZATION...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_update_person_links_authorized(self): person_data = { "id":"ab1a5788e5bae955c048748fa6af0e97", "links":[ { "id": "a4ffa24a9ef3cbcb8cfaa178c9329367", "note": "just a random repo" } ] } ...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_create_nested_person_links_authorized(self): person_data = { "id":"ab1a5788e5bae955c048748fa6af0e97", "contact_details":[ { "id": "a66cb422-eec3-4861-bae1-a64ae5dbde61", "links": [{ "url": "http://fa...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_update_nested_person_links_authorized(self): person_data = { "id":"8497ba86-7485-42d2-9596-2ab14520f1f4", "identifiers":[ { "id": "af7c01b5-1c4f-4c08-9174-3de5ff270bdb", "links": [{ "id": "9c9a2093-c...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_create_other_names_authorized(self): person_data = { "other_names": [ { "name": "jane", "family_name": "jambul", "given_name": "test person", "start_date": "1950-01-01", "end_...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_update_other_names_authorized(self): person_data = { "other_names": [ { "id": "cf93e73f-91b6-4fad-bf76-0782c80297a8", "family_name": "jambul", } ] } token = Token.objects.get(user__username="...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_delete_person_not_exist_unauthorized(self): response = self.client.delete("/en/persons/not_exist/") self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_delete_person_not_exist_authorized(self): token = Token.objects.get(user__username="admin") self.client.credentials(HTTP_AUTHORIZATION='Token ' + token.key) response = self.client.delete("/en/persons/not_exist/") self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_person_api_invalid_date(self): person_data = { "name": "joe", "family_name": "doe", "given_name": "joe jambul", "additional_name": "not john doe", "gender": "unknown", "summary": "person unit test api", "honorific_prefi...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_create_person_authorized_translated(self): person_data = { "name": "joe", "family_name": "doe", "given_name": "joe jambul", "additional_name": "bukan john doe", "gender": "tak tahu", "summary": "orang ujian", "honorific...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_create_person_identifier_blank_id_authorized(self): person_data = { "name": "joe", "family_name": "doe", "given_name": "joe jambul", "additional_name": "not john doe", "gender": "unknown", "summary": "person unit test api", ...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_create_person_links_blank_id_authorized(self): person_data = { "name": "joe", "family_name": "doe", "given_name": "joe jambul", "additional_name": "not john doe", "gender": "unknown", "summary": "person unit test api", ...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def test_create_person_with_all_field_birthdate_deathdate_blank_serializer(self): person_data = { "name": "joe", "family_name": "doe", "given_name": "joe jambul", "additional_name": "not john doe", "gender": "unknown", "summary": "person un...
Sinar/popit_ng
[ 21, 4, 21, 91, 1443407491 ]
def world_to_image_projection(p_world, intrinsics, pose_w2c): """Project points in the world frame to the image plane. Args: p_world: [HEIGHT, WIDTH, 3] points in the world's coordinate frame. intrinsics: [3, 3] camera's intrinsic matrix. pose_w2c: [3, 4] camera pose matrix (world to camera). Return...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def overlap_mask(depth1, pose1_c2w, depth2, pose2_c2w, intrinsics): """Compute the overlap masks of two views using triangulation. The masks have the same shape of the input images. A pixel value is true if it can be seen by both cameras. Arg...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def generate_from_meta(meta_data_path, pano_data_dir, pano_height=1024, pano_width=2048, output_height=512, output_width=512): """Generate the stereo image dataset from Matterport3D using the meta data. ...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def __init__(self, reader_class, common_queue, num_readers=4, reader_kwargs=None): """ParallelReader creates num_readers instances of the reader_class. Each instance is created by calling the `reader_class` function passing the arguments specified...
google-research/tf-slim
[ 334, 98, 334, 11, 1561681288 ]
def num_readers(self): return len(self._readers)
google-research/tf-slim
[ 334, 98, 334, 11, 1561681288 ]
def common_queue(self): return self._common_queue
google-research/tf-slim
[ 334, 98, 334, 11, 1561681288 ]
def read_up_to(self, queue, num_records, name=None): """Returns up to num_records (key, value pairs) produced by a reader. Will dequeue a work unit from queue if necessary (e.g., when the Reader needs to start reading from a new file since it has finished with the previous file). It may return less...
google-research/tf-slim
[ 334, 98, 334, 11, 1561681288 ]
def num_records_produced(self, name=None): """Returns the number of records this reader has produced. Args: name: A name for the operation (optional). Returns: An int64 Tensor. """ num_records = [r.num_records_produced() for r in self._readers] return math_ops.add_n(num_records, n...
google-research/tf-slim
[ 334, 98, 334, 11, 1561681288 ]
def parallel_read(data_sources, reader_class, num_epochs=None, num_readers=4, reader_kwargs=None, shuffle=True, dtypes=None, capacity=256, min_after_dequeue=128, ...
google-research/tf-slim
[ 334, 98, 334, 11, 1561681288 ]
def device_broadcast(x, num_devices): """Broadcast a value to all devices.""" return jax.pmap(lambda _: x)(jnp.arange(num_devices))
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def batched_loss_fn(model): """Apply loss function across a batch of examples.""" loss, metrics = jax.vmap(loss_fn, (None, 0, None))(model, batched_examples, static_batch_metadata) return jnp.mean(loss), metrics
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def _build_parallel_train_step(): """Builds an accelerated version of the train step function.""" # We need to wrap and unwrap so that the final function can be called with # keyword arguments, but we still maintain the proper axes. @functools.partial( jax.pmap, axis_name="devices", in_axes=(...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def warmup_train_step( optimizer, batched_example, static_batch_metadata, loss_fn, optimizer_is_replicated = False, profile = False, runner=None,
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def go(): # Note that value for learning_rate is arbitrary, but we pass it here to # warm up the jit cache (since we are passing a learning rate at training # time). res = parallel_train_step( replicated_optimizer, batched_example, static_batch_metadata, loss_fn, ...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def build_averaging_validator( loss_fn, valid_iterator_factory, objective_metric_name = None, include_total_counts = False, prefetch = True,
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def parallel_metrics_batch(model, batched_examples, batch_mask, static_metadata): loss, metrics = jax.vmap(loss_fn, (None, 0, None))(model, batched_examples, static_metadata) metrics["loss"] = loss metrics = jax.tree_map( ...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def __init__(self, spec): pass
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def default_matrix(self): """Returns default matrix for initialization. Size is taken from spec. """ raise NotImplementedError()
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def __init__(self, spec): """Initializer. Args: spec: hparams object with default value given by self.get_default_hparams(). """ super(LowRankDecompMatrixCompressor, self).__init__(spec) self._spec = spec self.uncompressed_size = 0 self.compressed_size = 0
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def get_default_hparams(): """Get a tf.HParams object with the default values for the hyperparameters. name: string name of the low-rank matrix decompressor specification. rank: integer rank of the low-rank decomposition that is performed. compressor_option: integer indica...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def __init__(self, scope='default_scope', spec=None, global_step=None): pass
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def get_update_op(self): """Update operator. Returns: TF operator that implements the update steps that may need to be applied periodically. """ raise NotImplementedError()
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def __init__(self, scope='default_scope', spec=None, global_step=None, layer=None): """Initializer. Args: scope: TF scope used for creating new TF variables. spec: compression hyper parameters default value given by self.get_defaul...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def get_default_hparams(): """Get a tf.HParams object with the default values for the hyperparameters. name: string name of the compression specification. Used for adding summaries and ops under a common tensorflow name_scope. alpha_decrement_value: float a positive real number ...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def compressed_matmul_keras(self, inputs, training=False): """Matmul with a convex combination of original and compressed weights.""" if training: compressed_mat = self.alpha * self.a_matrix_tfvar + ( 1 - self.alpha) * tf.matmul(self.b_matrix_tfvar, self.c_matrix_tfvar) return tf.matmul(in...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def maybe_update_alpha(): """Maybe update the alpha param. Checks if global_step is between begin_compression_step and end_compression_step, and if the current training step is a compression step. Returns: Boolean tensor whether the training step is a compression step. """ ...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def compressor_and_alpha_update_op_fn(): return self._compressor_and_alpha_update_op()
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def _compressor_op(self, matrix_compressor, a_matrix_tfvar): """Creates compressor op based on matrix_compressor. Meant to create the factors once at begin_compression_step. Args: matrix_compressor: specifies the matrix compressor object. a_matrix_tfvar: the tf tensor to be compressed. """ ...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def _compressor_and_alpha_update_op(self): """Applies compressor and also updates alpha.""" self._compressor_op(self.matrix_compressor, self.a_matrix_tfvar) self._update_alpha_op() self.last_alpha_update_step.assign(tf.cast(self._global_step, tf.int32))
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def __init__(self, scope, compression_spec, compressor, global_step=None): """Initializer. Args: scope: TF scope used for creating new TF variables. compression_spec: compression hyper parameters. compressor: matrix compressor object of class MatrixCompressorInferface. global_step: tf v...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def get_operator_hparam(self, hparam): """Returns the value of queried hparam of the compression operator.""" return self._compression_op_spec.get(hparam)
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def random_part_lens(max_n_parts, max_part_size): return tuple(random.randint(1, max_part_size) for _ in range(random.randint(1, max_n_parts)))
quantumlib/Cirq
[ 3678, 836, 3678, 314, 1513294909 ]
def test_shift_swap_network_gate_acquaintance_opps(left_part_lens, right_part_lens): gate = cca.ShiftSwapNetworkGate(left_part_lens, right_part_lens) n_qubits = gate.qubit_count() qubits = cirq.LineQubit.range(n_qubits) strategy = cirq.Circuit(gate(*qubits)) # actual_opps initial_mapping = {q:...
quantumlib/Cirq
[ 3678, 836, 3678, 314, 1513294909 ]
def test_shift_swap_network_gate_diagrams(left_part_lens, right_part_lens): gate = cca.ShiftSwapNetworkGate(left_part_lens, right_part_lens) n_qubits = gate.qubit_count() qubits = cirq.LineQubit.range(n_qubits) circuit = cirq.Circuit(gate(*qubits)) diagram = circuit_diagrams['undecomposed', left_p...
quantumlib/Cirq
[ 3678, 836, 3678, 314, 1513294909 ]
def test_shift_swap_network_gate_repr(left_part_lens, right_part_lens): gate = cca.ShiftSwapNetworkGate(left_part_lens, right_part_lens) cirq.testing.assert_equivalent_repr(gate) gate = cca.ShiftSwapNetworkGate(left_part_lens, right_part_lens, cirq.ZZ) cirq.testing.assert_equivalent_repr(gate)
quantumlib/Cirq
[ 3678, 836, 3678, 314, 1513294909 ]
def _read_proto_file(filename, proto): filename = filename # OSS: removed internal filename loading. with tf.io.gfile.GFile(filename, 'r') as proto_file: return text_format.ParseLines(proto_file, proto)
google-research/deeplab2
[ 878, 146, 878, 24, 1620859177 ]
def test_resnet50_encoder_creation(self): backbone_options = config_pb2.ModelOptions.BackboneOptions( name='resnet50', output_stride=32) encoder = builder.create_encoder( backbone_options, tf.keras.layers.experimental.SyncBatchNormalization) self.assertIsInstance(encoder, axial_resne...
google-research/deeplab2
[ 878, 146, 878, 24, 1620859177 ]
def test_mobilenet_encoder_creation(self, model_name): backbone_options = config_pb2.ModelOptions.BackboneOptions( name=model_name, use_squeeze_and_excite=True, output_stride=32) encoder = builder.create_encoder( backbone_options, tf.keras.layers.experimental.SyncBatchNormalization) ...
google-research/deeplab2
[ 878, 146, 878, 24, 1620859177 ]
def test_decoder_creation(self): proto_filename = os.path.join( _CONFIG_PATH, 'example_kitti-step_motion_deeplab.textproto') model_options = _read_proto_file(proto_filename, config_pb2.ModelOptions()) motion_decoder = builder.create_decoder( model_options, tf.keras.layers.experimental.SyncBa...
google-research/deeplab2
[ 878, 146, 878, 24, 1620859177 ]
def _cfg(url='', **kwargs): return { 'url': url, 'num_classes': 1000, 'input_size': (3, 224, 224), 'pool_size': None, 'crop_pct': .96, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'classifier': 'head', 'first_conv': 'stem.0', ...
rwightman/pytorch-image-models
[ 23978, 3956, 23978, 96, 1549086672 ]
def __init__(self, fn): super().__init__() self.fn = fn
rwightman/pytorch-image-models
[ 23978, 3956, 23978, 96, 1549086672 ]