没有使用tensorflow但是报错不能导入
收藏
快速回复
AI Studio平台使用 问答其他 257 0
没有使用tensorflow但是报错不能导入
收藏
快速回复
AI Studio平台使用 问答其他 257 0

我在这个平台使用xgboost调参, 但是会运行到一半报错不能导入 `tensorflow`。 我很明确地检查了我的代码没有导入这个包,这是为什么呢。

这里是报错信息

Cannot run import tensorflow because of system compatibility. AI Studio prepared an entire environment based on PaddlePaddle already. Please use PaddlePaddle to build your own model or application.

下面为部分代码

import json
import numpy as np
import pandas as pd
from sklearn.model_selection import GridSearchCV
import xgboost as xgb
import warnings
warnings.filterwarnings('ignore')
xgb_model = xgb.XGBRegressor(
    objective='reg:squarederror',
    seed=2023,
    learning_rate=0.1,
    n_estimators=300,
    colsample_bytree=1,
    subsample=1,
    reg_alpha=0.0,
    reg_lambda=1,
    tree_method='hist',
    device='cuda', # 使用 CUDA
    verbosity=2,
    eval_metric='mae',

    # 已调好的参数
)
train_params = {
    'max_depth': [5, 7, 9],
    'min_child_weight': [1, 3, 5, 7],
    # 'gamma': [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6],
    # 'subsample': [0.6, 0.7, 0.8, 0.9,1], 
    # 'colsample_bytree': [0.6, 0.7, 0.8, 0.9,1],
    # 'reg_alpha': [0.05, 0.1, 1, 2, 3], 
    # 'reg_lambda': [0.05, 0.1, 1, 2, 3],
}
gsearch = GridSearchCV(
    xgb_model, 
    param_grid=train_params, 
    cv=split_list, 
    verbose=3
)
print('============= start fit =============')
gsearch.fit(train_data[use_features], train_data['target'])
print('bset params:{0}'.format(gsearch.best_params_))
print('best score:{0}'.format(gsearch.best_score_))
print(gsearch.cv_results_['mean_test_score'])
print(gsearch.cv_results_['params'])
1
收藏
回复
在@后输入用户全名并按空格结束,可艾特全站任一用户