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

Method setUp

test/sequence/test_sequence_conv.py:80–145  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

78
79class TestSeqProject(OpTest):
80 def setUp(self):
81 self.init_test_case()
82 self.op_type = 'sequence_conv'
83
84 if (
85 self.context_length == 1
86 and self.context_start == 0
87 and self.padding_trainable
88 ):
89 print(
90 "If context_start is 0 "
91 "and context_length is 1,"
92 " padding_trainable should be false."
93 )
94 return
95
96 # one level, batch size
97 x = np.random.uniform(
98 0.1, 1, [self.input_size[0], self.input_size[1]]
99 ).astype('float32')
100 w = np.random.uniform(
101 0.1,
102 1,
103 [
104 self.context_length * self.input_size[1],
105 self.output_representation,
106 ],
107 ).astype('float32')
108
109 begin_pad = np.max([0, -self.context_start])
110 end_pad = np.max([0, self.context_start + self.context_length - 1])
111 total_pad = begin_pad + end_pad
112 padding_data = np.random.uniform(
113 0.1, 1, [total_pad, self.input_size[1]]
114 ).astype('float32')
115 self.pad_data = padding_data
116 self.inputs = {
117 'X': (x, self.lod),
118 'Filter': w,
119 }
120 self.inputs_val = ['X', 'Filter']
121 self.inputs_val_no_x = ['Filter']
122 self.inputs_val_no_f = ['X']
123
124 if total_pad != 0:
125 self.inputs['PaddingData'] = padding_data
126 self.inputs_val = ['X', 'PaddingData', 'Filter']
127 self.inputs_val_no_x = ['PaddingData', 'Filter']
128 self.inputs_val_no_f = ['PaddingData', 'X']
129
130 self.attrs = {
131 'contextStart': self.context_start,
132 'contextLength': self.context_length,
133 'paddingTrainable': self.padding_trainable,
134 'contextStride': self.context_stride,
135 }
136 out = seqconv(
137 x,

Callers

nothing calls this directly

Calls 6

init_test_caseMethod · 0.95
astypeMethod · 0.80
uniformMethod · 0.80
seqconvFunction · 0.70
printFunction · 0.50
maxMethod · 0.45

Tested by

no test coverage detected