Matter properties at the intermediate densities are still unknown to us. In this work, we use a neural network approach to study matter at intermediate densities to analyze the variation of the speed of sound and the measure of trace anomaly considering astrophysical constraints of mass–radius measurement of 18 neutron stars. Our numerical results show that there is a sharp rise in the speed of sound just beyond the saturation energy density. It attains a peak around 3–4 times the saturation energy density and, after that, decreases. This hints towards the appearance of new degrees of freedom and smooth transition from hadronic matter in massive stars. The trace anomaly is maximum at low density (surface of the stars) and decreases as we reach high density. It approaches zero and can even be slightly negative at the centre of massive stars. It has a negative trough beyond the maximal central densities of neutron stars. The change in sign of the trace anomaly hints towards a near-conformal matter at the centre of neutron stars, which may not necessarily be conformal quark matter.