• ALL >Computer and Education >courses >university courses >undergraduate courses >模式识别与人工智能 >zstu-(2021-2022)-1 >学生作业目录 >2019339964016 郭泽凯

  • 2019339964016 郭泽凯 作业九

    Abstract

    import tensorflow as tf import pandas as pd import matplotlib.pyplot as plt %matplotlib inline data = pd.read_csv('creditcard.csv') data.iloc[:,-1].value_counts() x = data.iloc[:, :-1].to_numpy() y = data.iloc[:, -1].to_numpy() #选择列数 model = tf.keras.Sequential() model.add(tf.keras.layers.Dense(4, input_shape=(30,),activation='relu')) model.add(tf.keras.layers.Dense(4, activation='relu')) model.add(tf.keras.layers.Dense(1, activation='sigmoid'))#最后一层激

    Words count(1465) photos count(3) videos count(0) Download files count(0)

    ————————————————
    import tensorflow as tf
    import pandas as pd
    import matplotlib.pyplot as plt
    %matplotlib inline
    data = pd.read_csv('creditcard.csv')

    data.iloc[:,-1].value_counts()

    x = data.iloc[:, :-1].to_numpy()
    y = data.iloc[:, -1].to_numpy() #选择列数
    model = tf.keras.Sequential()

    model.add(tf.keras.layers.Dense(4, input_shape=(30,),activation='relu'))
    model.add(tf.keras.layers.Dense(4, activation='relu'))
    model.add(tf.keras.layers.Dense(1, activation='sigmoid'))#最后一层激活函数是sigmod

    model.summary()
    model.compile(optimizer='adam',
    loss='binary_crossentropy',
    metrics=['acc']
    ) #metrics输出正确率,它是一个列表
    history = model.fit(x, y, epochs=10)#输出训练过程



    plt.plot(history.epoch, history.history.get('loss'))#绘制损失函数图像



    plt.plot(history.epoch, history.history.get('acc'))#绘制正确率图像



    0 Responses to 2019339964016 郭泽凯 作业九

    To post comment, you must login!