def _setup_initial_blobs(self):
MLTrainer._setup_initial_blobs(self)
self.output_conv_blob = "Conv_output_{}".format(self.model_id)
workspace.FeedBlob(self.output_conv_blob, np.zeros(1, dtype=np.float32))
self.conv_weights: List[str] = []
self.conv_biases: List[str] = []
for x in six.moves.range(len(self.dims) - 1):
dim_in = self.dims[x]
dim_out = self.dims[x + 1]
kernel_h = self.conv_height_kernels[x]
kernel_w = self.conv_width_kernels[x]
weight_shape = [dim_out, kernel_h, kernel_w, dim_in]
bias_shape = [dim_out, ]
conv_weight_name = "ConvWeights_" + str(x) + "_" + self.model_id
bias_name = "ConvBiases_" + str(x) + "_" + self.model_id
self.conv_weights.append(conv_weight_name)
self.conv_biases.append(bias_name)
conv_bias = np.zeros(shape=bias_shape, dtype=np.float32)
workspace.FeedBlob(bias_name, conv_bias)
conv_weights = scipy.stats.norm(0, np.sqrt(1 / dim_in)).rvs(
size=weight_shape
).astype(np.float32)
workspace.FeedBlob(conv_weight_name, conv_weights)
评论列表
文章目录