How to custom pretrained model to concat scalar data in FC layer

I have X-ray images and clinical data trying to predict regression problem.
How to custom library’s pretrained model able to inject scalar tensor vector after in FC layer after Flatten()?

I’ve modified Resnet34, by guiding from


class ConvnetBuilderRes34():
"""Class representing a convolutional network.
    c (int): size of the last layer
    is_multi (bool): is multilabel classification
    is_reg (bool): is a regression
    ps (float): dropout parameter for last layer
def __init__(self,c,is_multi,is_reg,ps=None):
    self.c,self.is_multi,self.is_reg = c,is_multi,is_reg = ps or 0.5
    self.lr_cut = 8
    res = resnet34(True)
    res.conv1 = nn.Conv2d(1, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)
    layers = children(res)[0:8]
    layers += [Flatten()]     
    self.top_model = nn.Sequential(*layers)
    fc_layers = self.create_fc_layer(6144, 1, p=None)
    self.n_fc = len(fc_layers)
    self.fc_model = to_gpu(nn.Sequential(*fc_layers))
    apply_init(self.fc_model, kaiming_normal)
    self.model = nn.Sequential(*(layers+fc_layers))           

def create_fc_layer(self, ni, nf, p, actn=None):
    if p: res.append(nn.Dropout(p=p))
    res.append(nn.Linear(in_features=ni, out_features=nf))
    if actn: res.append(actn())
    return res

def name(self): return "Resnet34"

def get_layer_groups(self, do_fc=False):
    if do_fc: 
        m,idxs = self.fc_model,[]
        m,idxs = self.model,[self.lr_cut,-self.n_fc]
    lgs = list(split_by_idxs(children(m),idxs))
    return lgs


class ConvLearnerRes34(ConvLearner):

def pretrained(cls, data, ps=None, **kwargs):
    model = ConvnetBuilderRes34(data.c, data.is_multi, data.is_reg)
    return cls(data,model,**kwargs)

# redefining freeze to freeze everything but last layer
def freeze(self):
    layers = children(self.model)
    n = len(layers)
    for l in layers:
        for p in l.parameters(): p.requires_grad=False
    l = layers[n-1]
    for p in l.parameters(): p.requires_grad=True
def unfreeze_prev_layer(self):
    layers = children(self.model)
    l = layers[9]
    for p in l.parameters(): p.requires_grad=True

Now I’m able to train 1channel Gray X-ray image and output as regression. If I would like to add a clinical data, such as age, sex,… etc after Flatten(), how can I do?

Do I need to create another Pytorch module? Where to feed it?