create layer from weights, share code