Diffraction of an electromagnetic wave by an open end of a coaxial line with an infinite flange adjoining a piecewise-uniform plane-layered lossy medium is considered. The direct problem is solved on the basis of admittance and impedance algorithms taking into account losses in the flange and the medium. For an infinite conductivity of the flange, a stationary functional for the input admittance is used to find an explicit solution in the form of an integral; numerical results are obtained. The inverse problem consisting in determination of the layer parameters (thickness, permittivity, and permeability) from known (experimental) values of the magnitude of the reflection coefficient at specified frequencies via minimization of the corresponding residual of the least-squares method is considered. It is proposed to increase the amount of experimental data through performance of measurements for several positions of the sample relative to the flange and for different impedance conditions behind the sample. In order to solve the inverse problem, a perceptron neural network is constructed. This approach reduces the solution time by several orders of magnitude.