size_batch = 1000

competition = AdversarialCompetition(
    size_batch=size_batch,
    true_model=GenerativeNormalModel(1, 2),
    discriminative=pipeline.make_pipeline(
        preprocessing.PolynomialFeatures(4),
        linear_model.LogisticRegression()),
    generative=GenerativeNormalModel(
        0, 1, updates=["mu", "sigma"]),
    gradient_descent=GradientDescent(
        0.03, inertia=0.0, annealing=100),
)

print(competition)

for i in range(200):
    if i % 50 == 0:
        competition.plot()
        plt.show()
        pass
    competition.iteration()

print("final model %s" % competition.generatives[-1])

competition.plot_params()
plt.show()

competition.plot_auc()
plt.show()
示例#2
0
np.random.seed(0)
size_batch = 1000

competition = AdversarialCompetition(
    size_batch=size_batch,
    true_model=GenerativeNormalMixtureModel([-3, 3], [1, 1]),
    discriminative=pipeline.make_pipeline(preprocessing.PolynomialFeatures(4),
                                          linear_model.LogisticRegression()),
    generative=GenerativeNormalMixtureModel([-1, 1], [1, 1],
                                            updates=["mu", "sigma"]),
    gradient_descent=GradientDescent(0.01, 0.5),
)

print(competition)

for i in range(1000):
    if i % 200 == 0:
        competition.plot()
        plt.show()
        pass
    competition.iteration()

print("final model %s" % competition.generatives[-1])

competition.plot_params()
plt.show()

competition.plot_auc()
plt.show()
示例#3
0
    discriminative=pipeline.make_pipeline(
        preprocessing.PolynomialFeatures(4),
        linear_model.LogisticRegression()),
    generative=GenerativeNormalQuasiMixtureModel(
        2.5,2.1,updates=["mu", "sigma"]),
    gradient_descent=GradientDescent(
        0.03, inertia=0.0, annealing=100),
    x_dataset = true_data
)

print(competition)

for i in range(1001):
    if i % 50 == 0:
        plt.figure()
        competition.plot()   
        pyplot.savefig('Pooling.png')
        pyplot.close()
        plt.figure()
        competition1.plot()
        competition2.plot()
        pyplot.savefig('Separating.png')
        pyplot.close()
        pass
    competition.iteration()
    competition1.iteration()
    competition2.iteration()

print("final model pooling %s" % competition.generatives[-1])
print("final model separating %s" % competition1.generatives[-1], competition2.generatives[-1])