A net assigning constant bool values to blobs. It is mainly used for initializing condition blobs, for example, in multi-task learning, we need to access reader_done blobs before reader_net run. In that case, the reader_done blobs must be initialized. Args: blobs_with_bool_value
(*blobs_with_bool_value)
| 95 | |
| 96 | |
| 97 | def BoolNet(*blobs_with_bool_value): |
| 98 | """A net assigning constant bool values to blobs. It is mainly used for |
| 99 | initializing condition blobs, for example, in multi-task learning, we |
| 100 | need to access reader_done blobs before reader_net run. In that case, |
| 101 | the reader_done blobs must be initialized. |
| 102 | |
| 103 | Args: |
| 104 | blobs_with_bool_value: one or more (blob, bool_value) pairs. The net will |
| 105 | assign each bool_value to the corresponding blob. |
| 106 | |
| 107 | returns |
| 108 | bool_net: A net assigning constant bool values to blobs. |
| 109 | |
| 110 | Examples: |
| 111 | - BoolNet((blob_1, bool_value_1), ..., (blob_n, bool_value_n)) |
| 112 | - BoolNet([(blob_1, net1), ..., (blob_n, bool_value_n)]) |
| 113 | - BoolNet((cond_1, bool_value_1)) |
| 114 | """ |
| 115 | blobs_with_bool_value = _MakeList(blobs_with_bool_value) |
| 116 | bool_net = core.Net('bool_net') |
| 117 | for blob, bool_value in blobs_with_bool_value: |
| 118 | out_blob = bool_net.ConstantFill( |
| 119 | [], |
| 120 | [blob], |
| 121 | shape=[], |
| 122 | value=bool_value, |
| 123 | dtype=core.DataType.BOOL) |
| 124 | bool_net.AddExternalOutput(out_blob) |
| 125 | |
| 126 | return bool_net |
| 127 | |
| 128 | |
| 129 | def NotNet(condition_blob_or_net): |
no test coverage detected
searching dependent graphs…