(self)
| 422 | self.assertEqual(np.int64(15), self.evaluate(v)) |
| 423 | |
| 424 | def testSomeErrors(self): |
| 425 | with ops_lib.Graph().as_default(): |
| 426 | v0 = variables.VariableV1([10.0], name="v0") |
| 427 | v1 = variables.VariableV1([20.0], name="v1") |
| 428 | v2 = variables.VariableV1([20.0], name="v2") |
| 429 | v2._set_save_slice_info( |
| 430 | variables.Variable.SaveSliceInfo("v1", [1], [0], [1])) |
| 431 | |
| 432 | # By default the name used for "v2" will be "v1" and raise an error. |
| 433 | with self.assertRaisesRegexp(ValueError, "same name: v1"): |
| 434 | saver_module.Saver([v0, v1, v2]) |
| 435 | |
| 436 | # The names are different and will work. |
| 437 | saver_module.Saver({"vee1": v1, "other": [v2]}) |
| 438 | |
| 439 | # Partitioned variables also cause name conflicts. |
| 440 | p_v1 = variable_scope.get_variable( |
| 441 | "p_v1", |
| 442 | shape=[4, 5], |
| 443 | partitioner=partitioned_variables.fixed_size_partitioner( |
| 444 | num_shards=2)) |
| 445 | p_v2 = variable_scope.get_variable( |
| 446 | "p_v2", |
| 447 | shape=[4, 5], |
| 448 | partitioner=partitioned_variables.fixed_size_partitioner( |
| 449 | num_shards=2)) |
| 450 | p_v2._name = "p_v1" |
| 451 | with self.assertRaisesRegexp(ValueError, "same name: p_v1"): |
| 452 | saver_module.Saver([p_v1, p_v2]) |
| 453 | |
| 454 | def testSameName(self): |
| 455 | with ops_lib.Graph().as_default(): |
nothing calls this directly
no test coverage detected