Adaptive Resource Optimization for Edge Inference with Goal-Oriented Communications