(self, X, dropout_for_eval)
| 1579 | dropout_for_eval=st.booleans(), |
| 1580 | ) |
| 1581 | def testDropout(self, X, dropout_for_eval): |
| 1582 | input_record = self.new_record(schema.Scalar((np.float32, (1,)))) |
| 1583 | schema.FeedRecord(input_record, [X]) |
| 1584 | d_output = self.model.Dropout( |
| 1585 | input_record, |
| 1586 | dropout_for_eval=dropout_for_eval |
| 1587 | ) |
| 1588 | self.assertEqual(schema.Scalar((np.float32, (1,))), d_output) |
| 1589 | self.model.output_schema = schema.Struct() |
| 1590 | |
| 1591 | train_init_net, train_net = self.get_training_nets() |
| 1592 | |
| 1593 | input_blob = input_record.field_blobs()[0] |
| 1594 | output_blob = d_output.field_blobs()[0] |
| 1595 | |
| 1596 | with_d_spec = OpSpec( |
| 1597 | "Dropout", |
| 1598 | [input_blob], |
| 1599 | [output_blob, None], |
| 1600 | {'is_test': 0, 'ratio': 0.5} |
| 1601 | ) |
| 1602 | |
| 1603 | without_d_spec = OpSpec( |
| 1604 | "Dropout", |
| 1605 | [input_blob], |
| 1606 | [output_blob, None], |
| 1607 | {'is_test': 1, 'ratio': 0.5} |
| 1608 | ) |
| 1609 | |
| 1610 | self.assertNetContainOps( |
| 1611 | train_net, |
| 1612 | [with_d_spec] |
| 1613 | ) |
| 1614 | |
| 1615 | eval_net = self.get_eval_net() |
| 1616 | predict_net = self.get_predict_net() |
| 1617 | |
| 1618 | if dropout_for_eval: |
| 1619 | self.assertNetContainOps( |
| 1620 | eval_net, |
| 1621 | [with_d_spec] |
| 1622 | ) |
| 1623 | self.assertNetContainOps( |
| 1624 | predict_net, |
| 1625 | [with_d_spec] |
| 1626 | ) |
| 1627 | else: |
| 1628 | self.assertNetContainOps( |
| 1629 | eval_net, |
| 1630 | [without_d_spec] |
| 1631 | ) |
| 1632 | self.assertNetContainOps( |
| 1633 | predict_net, |
| 1634 | [without_d_spec] |
| 1635 | ) |
| 1636 | |
| 1637 | workspace.RunNetOnce(train_init_net) |
| 1638 | workspace.RunNetOnce(train_net) |
nothing calls this directly
no test coverage detected