Hello, is there any guide for adapting cnn to regression?

I have images and csv labels, there are demos in keras, can I do it in pytorch, the following are the adaption codes in keras, how should I do the same work in pytorch ?

```
from keras.applications.xception import Xception
from keras.models import Model
model = Xception(weights='imagenet', include_top=True, input_shape=(299,299, 3))
x = model.get_layer(index=len(model.layers)-2).output
print(x)
x = Dense(1)(x)
model = Model(inputs=model.input, outputs=x)
model.summary()
```

```
opt = RMSprop(lr=0.0001)
model.compile(loss='mean_squared_error', optimizer=opt, metrics=['mae'])
```