MCPcopy Create free account
hub / github.com/pytorch/pytorch / testConv

Method testConv

caffe2/python/layers_test.py:2043–2114  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2041 rand_w, rand_b, s)
2042
2043 def testConv(self):
2044 batch_size = 50
2045 H = 1
2046 W = 10
2047 C = 50
2048 output_dims = 32
2049 kernel_h = 1
2050 kernel_w = 3
2051 stride_h = 1
2052 stride_w = 1
2053 pad_t = 0
2054 pad_b = 0
2055 pad_r = None
2056 pad_l = None
2057
2058 input_record = self.new_record(schema.Scalar((np.float32, (H, W, C))))
2059 X = np.random.random((batch_size, H, W, C)).astype(np.float32)
2060 schema.FeedRecord(input_record, [X])
2061 conv = self.model.Conv(
2062 input_record,
2063 output_dims,
2064 kernel_h=kernel_h,
2065 kernel_w=kernel_w,
2066 stride_h=stride_h,
2067 stride_w=stride_w,
2068 pad_t=pad_t,
2069 pad_b=pad_b,
2070 pad_r=pad_r,
2071 pad_l=pad_l,
2072 order='NHWC'
2073 )
2074
2075 self.assertEqual(
2076 schema.Scalar((np.float32, (output_dims,))),
2077 conv
2078 )
2079
2080 self.run_train_net_forward_only()
2081 output_record = schema.FetchRecord(conv)
2082 # check the number of output channels is the same as input in this example
2083 assert output_record.field_types()[0].shape == (H, W, output_dims)
2084 assert output_record().shape == (batch_size, H, W, output_dims)
2085
2086 train_init_net, train_net = self.get_training_nets()
2087 # Init net assertions
2088 init_ops = self.assertNetContainOps(
2089 train_init_net,
2090 [
2091 OpSpec("XavierFill", None, None),
2092 OpSpec("ConstantFill", None, None),
2093 ]
2094 )
2095 conv_spec = OpSpec(
2096 "Conv",
2097 [
2098 input_record.field_blobs()[0],
2099 init_ops[0].output[0],
2100 init_ops[1].output[0],

Callers

nothing calls this directly

Calls 12

OpSpecClass · 0.90
new_recordMethod · 0.80
astypeMethod · 0.80
ConvMethod · 0.80
get_training_netsMethod · 0.80
assertNetContainOpsMethod · 0.80
get_predict_netMethod · 0.80
get_eval_netMethod · 0.80
assertEqualMethod · 0.45
field_typesMethod · 0.45
field_blobsMethod · 0.45

Tested by

no test coverage detected