MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / set_data

Method set_data

test/sequence/test_sequence_pool.py:160–175  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

158 return [[13]]
159
160 def set_data(self):
161 self.op_type = 'sequence_pool'
162 x = np.random.uniform(0.1, 1, [13, 23]).astype('float32')
163 lod = self.set_lod()
164 level = len(lod) - 1
165 offset = convert_to_offset(lod)
166 for i in range(len(offset[level]) - 1):
167 l = offset[level][i + 1] - offset[level][i]
168 if l > 0:
169 x[offset[level][i] + np.random.randint(l), :] += 2.0
170
171 self.inputs = {'X': (x, lod)}
172
173 out = np.zeros((len(lod[level]), 23)).astype('float32')
174 self.outputs = {'Out': out}
175 return x, lod, offset, out
176
177 def compute(self, x, offset, out):
178 self.attrs = {"pad_value": 0.5, 'pooltype': "MAX"}

Callers

nothing calls this directly

Calls 5

set_lodMethod · 0.95
rangeFunction · 0.85
astypeMethod · 0.80
uniformMethod · 0.80
convert_to_offsetFunction · 0.70

Tested by

no test coverage detected